private void sendBuffer(boolean last) { socket.sendText(buffer, last); }
private void sendBuffer(boolean last) { socket.sendText(buffer, last); }
@SuppressWarnings("unchecked") void sendSyncObject(Object o, SendHandler handler) { if (o instanceof String) { webSocket.sendText((String) o, handler); } else { Object toSend = null; try { toSend = endpointWrapper.doEncode(session, o); } catch (final Exception e) { handler.onResult(new SendResult(e)); } if (toSend instanceof String) { webSocket.sendText((String) toSend, handler); } else if (toSend instanceof ByteBuffer) { webSocket.sendBinary(Utils.getRemainingArray((ByteBuffer) toSend), handler); } else if (toSend instanceof StringWriter) { StringWriter writer = (StringWriter) toSend; StringBuffer sb = writer.getBuffer(); webSocket.sendText(sb.toString(), handler); } else if (toSend instanceof ByteArrayOutputStream) { ByteArrayOutputStream baos = (ByteArrayOutputStream) toSend; webSocket.sendBinary(baos.toByteArray(), handler); } } }
@SuppressWarnings("unchecked") void sendSyncObject(Object o, SendHandler handler) { if (o instanceof String) { webSocket.sendText((String) o, handler); } else { Object toSend = null; try { toSend = endpointWrapper.doEncode(session, o); } catch (final Exception e) { handler.onResult(new SendResult(e)); } if (toSend instanceof String) { webSocket.sendText((String) toSend, handler); } else if (toSend instanceof ByteBuffer) { webSocket.sendBinary(Utils.getRemainingArray((ByteBuffer) toSend), handler); } else if (toSend instanceof StringWriter) { StringWriter writer = (StringWriter) toSend; StringBuffer sb = writer.getBuffer(); webSocket.sendText(sb.toString(), handler); } else if (toSend instanceof ByteArrayOutputStream) { ByteArrayOutputStream baos = (ByteArrayOutputStream) toSend; webSocket.sendBinary(baos.toByteArray(), handler); } } }
return webSocket.sendText((String) toSend); } else if (toSend instanceof ByteBuffer) { return webSocket.sendBinary(Utils.getRemainingArray((ByteBuffer) toSend)); StringWriter writer = (StringWriter) toSend; StringBuffer sb = writer.getBuffer(); return webSocket.sendText(sb.toString()); } else if (toSend instanceof ByteArrayOutputStream) { ByteArrayOutputStream baos = (ByteArrayOutputStream) toSend;
return webSocket.sendText((String) toSend); } else if (toSend instanceof ByteBuffer) { return webSocket.sendBinary(Utils.getRemainingArray((ByteBuffer) toSend)); StringWriter writer = (StringWriter) toSend; StringBuffer sb = writer.getBuffer(); return webSocket.sendText(sb.toString()); } else if (toSend instanceof ByteArrayOutputStream) { ByteArrayOutputStream baos = (ByteArrayOutputStream) toSend;
/** * Sends the message asynchronously. * <p> * IMPORTANT NOTE: There is no need to start new thread here. All writer are by default asynchronous, only * difference between sync and async writer are that sync send should wait for future.get(). * * @param message message to be sent * @param handler message sending callback handler * @param type message type */ private void sendAsync(final Object message, final SendHandler handler, final AsyncMessageType type) { switch (type) { case TEXT: webSocket.sendText((String) message, handler); break; case BINARY: webSocket.sendBinary(Utils.getRemainingArray((ByteBuffer) message), handler); break; case OBJECT: sendSyncObject(message, handler); break; } }
/** * Sends the message asynchronously. * <p> * IMPORTANT NOTE: There is no need to start new thread here. All writer are by default asynchronous, only * difference between sync and async writer are that sync send should wait for future.get(). * * @param message message to be sent * @param handler message sending callback handler * @param type message type */ private void sendAsync(final Object message, final SendHandler handler, final AsyncMessageType type) { switch (type) { case TEXT: webSocket.sendText((String) message, handler); break; case BINARY: webSocket.sendBinary(Utils.getRemainingArray((ByteBuffer) message), handler); break; case OBJECT: sendSyncObject(message, handler); break; } }
@Override public void sendText(String partialMessage, boolean isLast) throws IOException { checkNotNull(partialMessage, "partialMessage"); session.getDebugContext().appendLogMessage(LOGGER, Level.FINEST, DebugContext.Type.MESSAGE_OUT, "Sending partial text message: ", partialMessage); final Future<?> future = webSocket.sendText(partialMessage, isLast); try { processFuture(future); } finally { session.restartIdleTimeoutExecutor(); } }
@Override public void sendText(String text) throws IOException { checkNotNull(text, "text"); session.getDebugContext() .appendLogMessage(LOGGER, Level.FINEST, DebugContext.Type.MESSAGE_OUT, "Sending text message: ", text); final Future<?> future = webSocket.sendText(text); try { processFuture(future); } finally { session.restartIdleTimeoutExecutor(); } }
@Override public void sendText(String partialMessage, boolean isLast) throws IOException { checkNotNull(partialMessage, "partialMessage"); session.getDebugContext().appendLogMessage(LOGGER, Level.FINEST, DebugContext.Type.MESSAGE_OUT, "Sending partial text message: ", partialMessage); final Future<?> future = webSocket.sendText(partialMessage, isLast); try { processFuture(future); } finally { session.restartIdleTimeoutExecutor(); } }
@Override public void sendText(String text) throws IOException { checkNotNull(text, "text"); session.getDebugContext() .appendLogMessage(LOGGER, Level.FINEST, DebugContext.Type.MESSAGE_OUT, "Sending text message: ", text); final Future<?> future = webSocket.sendText(text); try { processFuture(future); } finally { session.restartIdleTimeoutExecutor(); } }
session.getDebugContext().appendLogMessage( LOGGER, Level.FINEST, DebugContext.Type.MESSAGE_OUT, "Sending text message: ", message); result = webSocket.sendText((String) message); break;
session.getDebugContext().appendLogMessage( LOGGER, Level.FINEST, DebugContext.Type.MESSAGE_OUT, "Sending text message: ", message); result = webSocket.sendText((String) message); break;