@Override public void sendText(final String message) { puts("MESSAGE", message); final List<Message<Object>> messages = QBit.factory().createProtocolParser().parse("", message); if (messages.size() == 1) { responseCounter++; final Response<Object> response = (Response<Object>) messages.get(0); if (response.wasErrors()) { failureCounter++; } } }
/** * Handles WebSocket messages and parses them into responses. * This does not handle batching or rather un-batching which we need for performance * we do handle batching in the parser/encoder. * * @param webSocketText websocket text */ private void handleWebSocketReplyMessage(final String webSocketText) { final List<Message<Object>> messages = QBit.factory().createProtocolParser().parse("", webSocketText); //noinspection Convert2streamapi for (Message<Object> message : messages) { if (message instanceof Response) { @SuppressWarnings("unchecked") final Response<Object> response = ((Response) message); final String[] split = StringScanner.split(response.returnAddress(), (char) PROTOCOL_ARG_SEPARATOR); final HandlerKey key = split.length == 2 ? new HandlerKey(split[1], response.id()) : new HandlerKey(split[0], response.id()); final Callback<Object> handler = handlers.get(key); if (handler != null) { handleAsyncCallback(response, handler); handlers.remove(key); } // else there was no handler, it was a one way method. } } }
/** * Handles WebSocket messages and parses them into responses. * This does not handle batching or rather un-batching which we need for performance * we do handle batching in the parser/encoder. * * @param webSocketText websocket text */ private void handleWebSocketReplyMessage(final String webSocketText) { final List<Message<Object>> messages = QBit.factory().createProtocolParser().parse("", webSocketText); //noinspection Convert2streamapi for (Message<Object> message : messages) { if (message instanceof Response) { @SuppressWarnings("unchecked") final Response<Object> response = ((Response) message); final String[] split = StringScanner.split(response.returnAddress(), (char) PROTOCOL_ARG_SEPARATOR); final HandlerKey key = split.length == 2 ? new HandlerKey(split[1], response.id()) : new HandlerKey(split[0], response.id()); final Callback<Object> handler = handlers.get(key); if (handler != null) { handleAsyncCallback(response, handler); handlers.remove(key); } // else there was no handler, it was a one way method. } } }
/** * Handles WebSocket messages and parses them into responses. * This does not handle batching or rather un-batching which we need for performance * we do handle batching in the parser/encoder. * * @param webSocketText websocket text */ private void handleWebSocketReplyMessage(final String webSocketText) { final List<Message<Object>> messages = QBit.factory().createProtocolParser().parse("", webSocketText); //noinspection Convert2streamapi for (Message<Object> message : messages) { if (message instanceof Response) { @SuppressWarnings("unchecked") final Response<Object> response = ((Response) message); final String[] split = StringScanner.split(response.returnAddress(), (char) PROTOCOL_ARG_SEPARATOR); final HandlerKey key = split.length == 2 ? new HandlerKey(split[1], response.id()) : new HandlerKey(split[0], response.id()); final Callback<Object> handler = handlers.get(key); if (handler != null) { handleAsyncCallback(response, handler); handlers.remove(key); } // else there was no handler, it was a one way method. } } }