public CloseMessage(final ByteBuffer[] buffers) { this(WebSockets.mergeBuffers(buffers)); }
/** * Sends a complete ping message, invoking the callback when complete * * @param data The data to send * @param wsChannel The web socket channel * @param callback The callback to invoke on completion * @param context The context object that will be passed to the callback on completion */ public static <T> void sendPing(final ByteBuffer[] data, final WebSocketChannel wsChannel, final WebSocketCallback<T> callback, T context) { sendInternal(mergeBuffers(data), WebSocketFrameType.PING, wsChannel, callback, context, -1); }
/** * Sends a complete pong message, invoking the callback when complete * * @param data The data to send * @param wsChannel The web socket channel * @param callback The callback to invoke on completion * @param context The context object that will be passed to the callback on completion */ public static <T> void sendPong(final ByteBuffer[] data, final WebSocketChannel wsChannel, final WebSocketCallback<T> callback, T context) { sendInternal(mergeBuffers(data), WebSocketFrameType.PONG, wsChannel, callback, context, -1); }
/** * Sends a complete ping message, invoking the callback when complete * * @param data The data to send * @param wsChannel The web socket channel * @param callback The callback to invoke on completion */ public static void sendPing(final ByteBuffer[] data, final WebSocketChannel wsChannel, final WebSocketCallback<Void> callback) { sendInternal(mergeBuffers(data), WebSocketFrameType.PING, wsChannel, callback, null, -1); }
/** * Sends a complete binary message, invoking the callback when complete * * @param data The data to send * @param wsChannel The web socket channel * @param callback The callback to invoke on completion * @param timeoutmillis the timeout in milliseconds */ public static void sendBinary(final ByteBuffer[] data, final WebSocketChannel wsChannel, final WebSocketCallback<Void> callback, long timeoutmillis) { sendInternal(mergeBuffers(data), WebSocketFrameType.BINARY, wsChannel, callback, null, timeoutmillis); }
/** * Sends a complete binary message using blocking IO * * @param data The data to send * @param wsChannel The web socket channel */ public static void sendBinaryBlocking(final ByteBuffer[] data, final WebSocketChannel wsChannel) throws IOException { sendBlockingInternal(mergeBuffers(data), WebSocketFrameType.BINARY, wsChannel); }
/** * Sends a complete ping message, invoking the callback when complete * * @param data The data to send * @param wsChannel The web socket channel * @param callback The callback to invoke on completion * @param timeoutmillis the timeout in milliseconds */ public static void sendPing(final ByteBuffer[] data, final WebSocketChannel wsChannel, final WebSocketCallback<Void> callback, long timeoutmillis) { sendInternal(mergeBuffers(data), WebSocketFrameType.PING, wsChannel, callback, null, timeoutmillis); }
/** * Sends a complete ping message using blocking IO * * @param data The data to send * @param wsChannel The web socket channel */ public static void sendPingBlocking(final ByteBuffer[] data, final WebSocketChannel wsChannel) throws IOException { sendBlockingInternal(mergeBuffers(data), WebSocketFrameType.PING, wsChannel); }
/** * Sends a complete pong message, invoking the callback when complete * * @param data The data to send * @param wsChannel The web socket channel * @param callback The callback to invoke on completion * @param context The context object that will be passed to the callback on completion * @param timeoutmillis the timeout in milliseconds */ public static <T> void sendPong(final ByteBuffer[] data, final WebSocketChannel wsChannel, final WebSocketCallback<T> callback, T context, long timeoutmillis) { sendInternal(mergeBuffers(data), WebSocketFrameType.PONG, wsChannel, callback, context, timeoutmillis); }
/** * Sends a complete binary message, invoking the callback when complete * * @param data The data to send * @param wsChannel The web socket channel * @param callback The callback to invoke on completion * @param context The context object that will be passed to the callback on completion * @param timeoutmillis the timeout in milliseconds */ public static <T> void sendBinary(final ByteBuffer[] data, final WebSocketChannel wsChannel, final WebSocketCallback<T> callback, T context, long timeoutmillis) { sendInternal(mergeBuffers(data), WebSocketFrameType.BINARY, wsChannel, callback, context, timeoutmillis); }
/** * Sends a complete ping message, invoking the callback when complete * * @param data The data to send * @param wsChannel The web socket channel * @param callback The callback to invoke on completion * @param context The context object that will be passed to the callback on completion * @param timeoutmillis the timeout in milliseconds */ public static <T> void sendPing(final ByteBuffer[] data, final WebSocketChannel wsChannel, final WebSocketCallback<T> callback, T context, long timeoutmillis) { sendInternal(mergeBuffers(data), WebSocketFrameType.PING, wsChannel, callback, context, timeoutmillis); }
/** * Sends a complete pong message, invoking the callback when complete * * @param data The data to send * @param wsChannel The web socket channel * @param callback The callback to invoke on completion */ public static void sendPong(final ByteBuffer[] data, final WebSocketChannel wsChannel, final WebSocketCallback<Void> callback) { sendInternal(mergeBuffers(data), WebSocketFrameType.PONG, wsChannel, callback, null, -1); }
/** * Sends a complete pong message, invoking the callback when complete * * @param data The data to send * @param wsChannel The web socket channel * @param callback The callback to invoke on completion * @param timeoutmillis the timeout in milliseconds */ public static void sendPong(final ByteBuffer[] data, final WebSocketChannel wsChannel, final WebSocketCallback<Void> callback, long timeoutmillis) { sendInternal(mergeBuffers(data), WebSocketFrameType.PONG, wsChannel, callback, null, timeoutmillis); }
/** * Sends a complete pong message using blocking IO * * @param data The data to send * @param wsChannel The web socket channel */ public static void sendPongBlocking(final ByteBuffer[] data, final WebSocketChannel wsChannel) throws IOException { sendBlockingInternal(mergeBuffers(data), WebSocketFrameType.PONG, wsChannel); }
/** * Sends a complete binary message, invoking the callback when complete * * @param data The data to send * @param wsChannel The web socket channel * @param callback The callback to invoke on completion */ public static void sendBinary(final ByteBuffer[] data, final WebSocketChannel wsChannel, final WebSocketCallback<Void> callback) { sendInternal(mergeBuffers(data), WebSocketFrameType.BINARY, wsChannel, callback, null, -1); }
/** * Sends a complete binary message, invoking the callback when complete * * @param data The data to send * @param wsChannel The web socket channel * @param callback The callback to invoke on completion * @param context The context object that will be passed to the callback on completion */ public static <T> void sendBinary(final ByteBuffer[] data, final WebSocketChannel wsChannel, final WebSocketCallback<T> callback, T context) { sendInternal(mergeBuffers(data), WebSocketFrameType.BINARY, wsChannel, callback, context, -1); }
@Override protected void onFullBinaryMessage(final WebSocketChannel channel, final BufferedBinaryMessage message) throws IOException { ready(); Pooled<ByteBuffer[]> data = message.getData(); try { this.onBinaryCallback.accept(WebSockets.mergeBuffers(data.getResource())); } finally { data.free(); } }
@Override protected void onFullBinaryMessage(WebSocketChannel channel, BufferedBinaryMessage message) throws IOException { Pooled<ByteBuffer[]> pulledData = message.getData(); try { ByteBuffer[] resource = pulledData.getResource(); ByteBuffer buffer = WebSockets.mergeBuffers(resource); handler.onMessage(context, buffer.array()); } finally { pulledData.discard(); } }
/** * Sends a complete pong message, invoking the callback when complete * * @param data The data to send * @param wsChannel The web socket channel * @param callback The callback to invoke on completion * @param timeoutmillis the timeout in milliseconds */ public static void sendPong(final ByteBuffer[] data, final WebSocketChannel wsChannel, final WebSocketCallback<Void> callback, long timeoutmillis) { sendInternal(mergeBuffers(data), WebSocketFrameType.PONG, wsChannel, callback, null, timeoutmillis); }
/** * Sends a complete binary message, invoking the callback when complete * * @param data The data to send * @param wsChannel The web socket channel * @param callback The callback to invoke on completion * @param timeoutmillis the timeout in milliseconds */ public static void sendBinary(final ByteBuffer[] data, final WebSocketChannel wsChannel, final WebSocketCallback<Void> callback, long timeoutmillis) { sendInternal(mergeBuffers(data), WebSocketFrameType.BINARY, wsChannel, callback, null, timeoutmillis); }