/** * Sends a complete close message, invoking the callback when complete * * @param closeMessage the close message * @param wsChannel The web socket channel */ public static void sendCloseBlocking(final CloseMessage closeMessage, final WebSocketChannel wsChannel) throws IOException { wsChannel.setCloseReason(closeMessage.getReason()); wsChannel.setCloseCode(closeMessage.getCode()); sendBlockingInternal(closeMessage.toByteBuffer(), WebSocketFrameType.CLOSE, wsChannel); } /**
/** * Sends a complete close message, invoking the callback when complete * * @param code The close code * @param wsChannel The web socket channel * @param callback The callback to invoke on completion */ public static void sendClose(final int code, String reason, final WebSocketChannel wsChannel, final WebSocketCallback<Void> callback) { sendClose(new CloseMessage(code, reason), wsChannel, callback); }
/** * Sends a complete close message, invoking the callback when complete * * @param data The data to send * @param wsChannel The web socket channel */ public static void sendCloseBlocking(final ByteBuffer[] data, final WebSocketChannel wsChannel) throws IOException { sendCloseBlocking(new CloseMessage(data), wsChannel); }
@Override protected void onFullCloseMessage(WebSocketChannel channel, BufferedBinaryMessage message) { CloseMessage closeMessage = new CloseMessage(message.getData().getResource()); this.session.handleClose(new CloseStatus(closeMessage.getCode(), closeMessage.getReason())); message.getData().free(); }
protected void onFullCloseMessage(final WebSocketChannel channel, BufferedBinaryMessage message) throws IOException { Pooled<ByteBuffer[]> data = message.getData(); try { CloseMessage cm = new CloseMessage(data.getResource()); onCloseMessage(cm, channel); if (!channel.isCloseFrameSent()) { WebSockets.sendClose(cm, channel, null); } } finally { data.close(); } }
private void checkMaxSize(StreamSourceFrameChannel channel, int res) throws IOException { if(res > 0) { currentSize += res; } if (maxMessageSize > 0 && currentSize > maxMessageSize) { WebSockets.sendClose(new CloseMessage(CloseMessage.MSG_TOO_BIG, WebSocketMessages.MESSAGES.messageToBig(maxMessageSize)), channel.getWebSocketChannel(), null); throw new IOException(WebSocketMessages.MESSAGES.messageToBig(maxMessageSize)); } }
@Override protected void handleBrokenSourceChannel(Throwable e) { if (e instanceof UnsupportedEncodingException) { getFramePriority().immediateCloseFrame(); WebSockets.sendClose(new CloseMessage(CloseMessage.MSG_CONTAINS_INVALID_DATA, e.getMessage()).toByteBuffer(), this, null); } else if (e instanceof WebSocketInvalidCloseCodeException) { WebSockets.sendClose(new CloseMessage(CloseMessage.WRONG_CODE, e.getMessage()).toByteBuffer(), this, null); } else if (e instanceof WebSocketFrameCorruptedException) { getFramePriority().immediateCloseFrame(); WebSockets.sendClose(new CloseMessage(CloseMessage.WRONG_CODE, e.getMessage()).toByteBuffer(), this, null); } }
@Override protected void resumeReceiving() { getDelegate().resumeReceives(); }
@Override public Mono<Void> close(CloseStatus status) { CloseMessage cm = new CloseMessage(status.getCode(), status.getReason()); if (!getDelegate().isCloseFrameSent()) { WebSockets.sendClose(cm, getDelegate(), null); } return Mono.empty(); }
@Override protected void onFullTextMessage(WebSocketChannel channel, BufferedTextMessage message) { this.session.handleMessage(Type.TEXT, toMessage(Type.TEXT, message.getData())); }
@Override protected StreamSourceFrameChannel createChannel(FrameHeaderData frameHeaderData, PooledByteBuffer frameData) { PartialFrame partialFrame = (PartialFrame) frameHeaderData; StreamSourceFrameChannel channel = partialFrame.getChannel(frameData); if (channel.getType() == WebSocketFrameType.CLOSE) { if(!closeFrameSent) { closeInitiatedByRemotePeer = true; } closeFrameReceived = true; } return channel; }
@Override protected void suspendReceiving() { getDelegate().suspendReceives(); }
private void checkMaxSize(StreamSourceFrameChannel channel, int res) throws IOException { currentSize += res; if (maxMessageSize > 0 && currentSize > maxMessageSize) { getData().free(); WebSockets.sendClose(new CloseMessage(CloseMessage.MSG_TOO_BIG, WebSocketMessages.MESSAGES.messageToBig(maxMessageSize)), channel.getWebSocketChannel(), null); throw new IOException(WebSocketMessages.MESSAGES.messageToBig(maxMessageSize)); } }
/** * Sends a complete close message, invoking the callback when complete * * @param code The close code * @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 sendClose(final int code, String reason, final WebSocketChannel wsChannel, final WebSocketCallback<T> callback, T context) { sendClose(new CloseMessage(code, reason), wsChannel, callback, context); }
/** * Sends a complete close message, invoking the callback when complete * * @param code * @param wsChannel The web socket channel */ public static void sendCloseBlocking(final int code, String reason, final WebSocketChannel wsChannel) throws IOException { sendCloseBlocking(new CloseMessage(code, reason), wsChannel); } /**
/** * Sends a complete close 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 sendClose(final ByteBuffer data, final WebSocketChannel wsChannel, final WebSocketCallback<Void> callback) { CloseMessage sm = new CloseMessage(data); sendClose(sm, wsChannel, callback); }
/** * Sends a complete close message, invoking the callback when complete * * @param data The data to send * @param wsChannel The web socket channel */ public static void sendCloseBlocking(final ByteBuffer data, final WebSocketChannel wsChannel) throws IOException { sendCloseBlocking(new CloseMessage(data), wsChannel); }
/** * Sends a complete close 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 sendClose(final ByteBuffer data, final WebSocketChannel wsChannel, final WebSocketCallback<T> callback, T context) { CloseMessage sm = new CloseMessage(data); sendClose(sm, wsChannel, callback, context); }
/** * Sends a complete close 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 sendClose(final ByteBuffer[] data, final WebSocketChannel wsChannel, final WebSocketCallback<Void> callback) { CloseMessage sm = new CloseMessage(data); sendClose(sm, wsChannel, callback); }
/** * Sends a complete close 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 sendClose(final ByteBuffer[] data, final WebSocketChannel wsChannel, final WebSocketCallback<T> callback, T context) { CloseMessage sm = new CloseMessage(data); sendClose(sm, wsChannel, callback, context); }