protected WsMessage emptyPongMessage(IoSessionEx session) throws Exception { WsPongMessage pong = new WsPongMessage(); return pong; }
protected IoBufferEx doPongEncode(IoBufferAllocatorEx<?> allocator, int flags, WsMessage message) { WsPongMessage ping = (WsPongMessage)message; assert ping.getBytes().remaining() == 0 : "PONG with payload not supported"; ByteBuffer text = allocator.allocate(EMPTY_PONG_BYTES.length, flags); int offset = text.position(); text.put(EMPTY_PONG_BYTES); text.flip(); text.position(offset); return allocator.wrap(text, flags); }
@Override protected DecodingState finishDecode(byte lengthByte1, ProtocolDecoderOutput out) throws Exception { if ( lengthByte1 != (byte)0 ) { throw new ProtocolDecoderException("Pong frame length must be 0, but got: " + Integer.toHexString((lengthByte1 & 0xff))); } out.write(new WsPongMessage(allocator.wrap(allocator.allocate(0)))); return READ_FRAME_TYPE; } };
@Override protected IoBufferEx doPongEncode(IoBufferAllocatorEx<?> allocator, int flags, WsMessage message) { WsPongMessage ping = (WsPongMessage)message; assert ping.getBytes().remaining() == 0 : "PONG with payload not supported"; ByteBuffer text = allocator.allocate(EMPTY_PONG_BYTES.length, flags); int offset = text.position(); text.put(EMPTY_PONG_BYTES); text.flip(); text.position(offset); return allocator.wrap(text, flags); }
@Override protected void wsPingReceived(NextFilter nextFilter, IoSession session, WsPingMessage wsPing) throws Exception { WsPongMessage reply = new WsPongMessage(wsPing.getBytes()); nextFilter.filterWrite(session, new DefaultWriteRequestEx(reply)); }
WsPongMessage pong = new WsPongMessage(payload); session.write(pong); break;
break; case PONG: newWsMessage = new WsPongMessage(buf); break; default:
WsPongMessage pong = new WsPongMessage(payload); session.write(pong); break;
IoBufferEx emptyBuf = allocator.wrap(allocator.allocate(0)); emptyBuf.mark(); WsMessage emptyPong = new WsPongMessage(emptyBuf); session.write(emptyPong); break;
break; case PONG: out.write(new WsPongMessage(buf)); break; case CLOSE: