@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); } }
/** * Returns a new {@link StreamSinkFrameChannel} for sending the given {@link WebSocketFrameType} with the given payload. * If this method is called multiple times, subsequent {@link StreamSinkFrameChannel}'s will not be writable until all previous frames * were completely written. * * @param type The {@link WebSocketFrameType} for which a {@link StreamSinkChannel} should be created */ public final StreamSinkFrameChannel send(WebSocketFrameType type) throws IOException { if(closeFrameSent || (closeFrameReceived && type != WebSocketFrameType.CLOSE)) { throw WebSocketMessages.MESSAGES.channelClosed(); } if (isWritesBroken()) { throw WebSocketMessages.MESSAGES.streamIsBroken(); } StreamSinkFrameChannel ch = createStreamSinkChannel(type); getFramePriority().addToOrderQueue(ch); if (type == WebSocketFrameType.CLOSE) { closeFrameSent = true; } return ch; }
@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 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); } }
/** * Returns a new {@link StreamSinkFrameChannel} for sending the given {@link WebSocketFrameType} with the given payload. * If this method is called multiple times, subsequent {@link StreamSinkFrameChannel}'s will not be writable until all previous frames * were completely written. * * @param type The {@link WebSocketFrameType} for which a {@link StreamSinkChannel} should be created */ public final StreamSinkFrameChannel send(WebSocketFrameType type) throws IOException { if(closeFrameSent || (closeFrameReceived && type != WebSocketFrameType.CLOSE)) { throw WebSocketMessages.MESSAGES.channelClosed(); } if (isWritesBroken()) { throw WebSocketMessages.MESSAGES.streamIsBroken(); } StreamSinkFrameChannel ch = createStreamSinkChannel(type); getFramePriority().addToOrderQueue(ch); if (type == WebSocketFrameType.CLOSE) { closeFrameSent = true; } return ch; }
/** * Returns a new {@link StreamSinkFrameChannel} for sending the given {@link WebSocketFrameType} with the given payload. * If this method is called multiple times, subsequent {@link StreamSinkFrameChannel}'s will not be writable until all previous frames * were completely written. * * @param type The {@link WebSocketFrameType} for which a {@link StreamSinkChannel} should be created */ public final StreamSinkFrameChannel send(WebSocketFrameType type) throws IOException { if(closeFrameSent || (closeFrameReceived && type != WebSocketFrameType.CLOSE)) { throw WebSocketMessages.MESSAGES.channelClosed(); } if (isWritesBroken()) { throw WebSocketMessages.MESSAGES.streamIsBroken(); } StreamSinkFrameChannel ch = createStreamSinkChannel(type); getFramePriority().addToOrderQueue(ch); if (type == WebSocketFrameType.CLOSE) { closeFrameSent = true; } return ch; }