@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 public void handleEvent(WebSocketChannel channel) { try { final StreamSourceFrameChannel result = channel.receive(); if (result == null) { return; } else if (result.getType() == WebSocketFrameType.BINARY) { onBinary(channel, result); } else if (result.getType() == WebSocketFrameType.TEXT) { onText(channel, result); } else if (result.getType() == WebSocketFrameType.PONG) { onPong(channel, result); } else if (result.getType() == WebSocketFrameType.PING) { onPing(channel, result); } else if (result.getType() == WebSocketFrameType.CLOSE) { onClose(channel, result); } } catch (IOException e) { onError(channel, e); } }
/** * Utility method that reads a full text or binary message, including all fragmented parts. Once the full message is * read then the {@link #onFullTextMessage(WebSocketChannel, BufferedTextMessage)} or * {@link #onFullBinaryMessage(WebSocketChannel, BufferedBinaryMessage)} method will be invoked. * * @param messageChannel The message channel */ protected final void bufferFullMessage(StreamSourceFrameChannel messageChannel) { if (messageChannel.getType() == WebSocketFrameType.TEXT) { readBufferedText(messageChannel, new BufferedTextMessage(getMaxTextBufferSize(), true)); } else if (messageChannel.getType() == WebSocketFrameType.BINARY) { readBufferedBinary(messageChannel, false, new BufferedBinaryMessage(getMaxBinaryBufferSize(), true)); } else if (messageChannel.getType() == WebSocketFrameType.PONG) { readBufferedBinary(messageChannel, true, new BufferedBinaryMessage(getMaxPongBufferSize(), true)); } else if (messageChannel.getType() == WebSocketFrameType.PING) { readBufferedBinary(messageChannel, true, new BufferedBinaryMessage(getMaxPingBufferSize(), true)); } else if (messageChannel.getType() == WebSocketFrameType.CLOSE) { readBufferedBinary(messageChannel, true, new BufferedBinaryMessage(getMaxCloseBufferSize(), true)); } }
@Override public void complete(WebSocketChannel channel, BufferedBinaryMessage context) { try { WebSocketFrameType type = messageChannel.getType(); if (!controlFrame) { onFullBinaryMessage(channel, buffer); } else if (type == WebSocketFrameType.PONG) { onFullPongMessage(channel, buffer); } else if (type == WebSocketFrameType.PING) { onFullPingMessage(channel, buffer); } else if (type == WebSocketFrameType.CLOSE) { onFullCloseMessage(channel, buffer); } } catch (IOException e) { AbstractReceiveListener.this.onError(channel, e); } }
@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 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 public void handleEvent(WebSocketChannel channel) { try { final StreamSourceFrameChannel result = channel.receive(); if (result == null) { return; } else if (result.getType() == WebSocketFrameType.BINARY) { onBinary(channel, result); } else if (result.getType() == WebSocketFrameType.TEXT) { onText(channel, result); } else if (result.getType() == WebSocketFrameType.PONG) { onPong(channel, result); } else if (result.getType() == WebSocketFrameType.PING) { onPing(channel, result); } else if (result.getType() == WebSocketFrameType.CLOSE) { onClose(channel, result); } } catch (IOException e) { onError(channel, e); } }
@Override public void handleEvent(WebSocketChannel channel) { try { final StreamSourceFrameChannel result = channel.receive(); if (result == null) { return; } else if (result.getType() == WebSocketFrameType.BINARY) { onBinary(channel, result); } else if (result.getType() == WebSocketFrameType.TEXT) { onText(channel, result); } else if (result.getType() == WebSocketFrameType.PONG) { onPong(channel, result); } else if (result.getType() == WebSocketFrameType.PING) { onPing(channel, result); } else if (result.getType() == WebSocketFrameType.CLOSE) { onClose(channel, result); } } catch (IOException e) { onError(channel, e); } }
/** * Utility method that reads a full text or binary message, including all fragmented parts. Once the full message is * read then the {@link #onFullTextMessage(WebSocketChannel, BufferedTextMessage)} or * {@link #onFullBinaryMessage(WebSocketChannel, BufferedBinaryMessage)} method will be invoked. * * @param messageChannel The message channel */ protected final void bufferFullMessage(StreamSourceFrameChannel messageChannel) { if (messageChannel.getType() == WebSocketFrameType.TEXT) { readBufferedText(messageChannel, new BufferedTextMessage(getMaxTextBufferSize(), true)); } else if (messageChannel.getType() == WebSocketFrameType.BINARY) { readBufferedBinary(messageChannel, false, new BufferedBinaryMessage(getMaxBinaryBufferSize(), true)); } else if (messageChannel.getType() == WebSocketFrameType.PONG) { readBufferedBinary(messageChannel, true, new BufferedBinaryMessage(getMaxPongBufferSize(), true)); } else if (messageChannel.getType() == WebSocketFrameType.PING) { readBufferedBinary(messageChannel, true, new BufferedBinaryMessage(getMaxPingBufferSize(), true)); } else if (messageChannel.getType() == WebSocketFrameType.CLOSE) { readBufferedBinary(messageChannel, true, new BufferedBinaryMessage(getMaxCloseBufferSize(), true)); } }
/** * Utility method that reads a full text or binary message, including all fragmented parts. Once the full message is * read then the {@link #onFullTextMessage(WebSocketChannel, BufferedTextMessage)} or * {@link #onFullBinaryMessage(WebSocketChannel, BufferedBinaryMessage)} method will be invoked. * * @param messageChannel The message channel */ protected final void bufferFullMessage(StreamSourceFrameChannel messageChannel) { if (messageChannel.getType() == WebSocketFrameType.TEXT) { readBufferedText(messageChannel, new BufferedTextMessage(getMaxTextBufferSize(), true)); } else if (messageChannel.getType() == WebSocketFrameType.BINARY) { readBufferedBinary(messageChannel, false, new BufferedBinaryMessage(getMaxBinaryBufferSize(), true)); } else if (messageChannel.getType() == WebSocketFrameType.PONG) { readBufferedBinary(messageChannel, true, new BufferedBinaryMessage(getMaxPongBufferSize(), true)); } else if (messageChannel.getType() == WebSocketFrameType.PING) { readBufferedBinary(messageChannel, true, new BufferedBinaryMessage(getMaxPingBufferSize(), true)); } else if (messageChannel.getType() == WebSocketFrameType.CLOSE) { readBufferedBinary(messageChannel, true, new BufferedBinaryMessage(getMaxCloseBufferSize(), true)); } }
@Override public void complete(WebSocketChannel channel, BufferedBinaryMessage context) { try { WebSocketFrameType type = messageChannel.getType(); if (!controlFrame) { onFullBinaryMessage(channel, buffer); } else if (type == WebSocketFrameType.PONG) { onFullPongMessage(channel, buffer); } else if (type == WebSocketFrameType.PING) { onFullPingMessage(channel, buffer); } else if (type == WebSocketFrameType.CLOSE) { onFullCloseMessage(channel, buffer); } } catch (IOException e) { AbstractReceiveListener.this.onError(channel, e); } }
@Override public void complete(WebSocketChannel channel, BufferedBinaryMessage context) { try { WebSocketFrameType type = messageChannel.getType(); if (!controlFrame) { onFullBinaryMessage(channel, buffer); } else if (type == WebSocketFrameType.PONG) { onFullPongMessage(channel, buffer); } else if (type == WebSocketFrameType.PING) { onFullPingMessage(channel, buffer); } else if (type == WebSocketFrameType.CLOSE) { onFullCloseMessage(channel, buffer); } } catch (IOException e) { AbstractReceiveListener.this.onError(channel, e); } }