/** {@inheritDoc} */ @Override public void messageReceived(NextFilter next, IoSession session, Object message) throws Exception { if (message instanceof IoBuffer) { IoBuffer out = (IoBuffer) message; if (headers != null) { IoBuffer header = IoBuffer.allocate(12); header.putLong(System.currentTimeMillis()); header.putInt(out.limit() - out.position()); header.flip(); headers.write(header.buf()); } if (raw != null) { raw.write(out.asReadOnlyBuffer().buf()); } } next.messageReceived(session, message); }
encoder.decode(byteBuffer.buf(), charBuffer, false); char[] buf = new char[charBuffer.position()]; charBuffer.flip();
header.put((byte) (isClient ? 0x00 : 0x01)); header.flip(); headers.write(header.buf()); session.getFilterChain().addFirst("dump", new NetworkDumpFilter(headers, raw)); } finally {
/** * {@inheritDoc} */ @Override public ByteBuffer buf() { return buf.buf(); }
/** * {@inheritDoc} */ @Override public ByteBuffer buf() { return buf.buf(); }
/** * {@inheritDoc} */ @Override public IoBuffer put(IoBuffer src) { return put(src.buf()); }
/** * {@inheritDoc} */ @Override public ByteBuffer allocateNioBuffer(int capacity, boolean direct) { return allocate(capacity, direct).buf(); }
/** * {@inheritDoc} */ @Override public ByteBuffer allocateNioBuffer(int capacity, boolean direct) { return allocate(capacity, direct).buf(); }
@Override protected SocketAddress receive(DatagramChannel handle, IoBuffer buffer) throws Exception { return handle.receive(buffer.buf()); }
/** * {@inheritDoc} */ @Override public IoBuffer put(IoBuffer src) { return put(src.buf()); }
/** {@inheritDoc} */ @Override public String readUTFBytes(int length) { int limit = buffer.limit(); final ByteBuffer strBuf = buffer.buf(); strBuf.limit(strBuf.position() + length); final String string = AMF.CHARSET.decode(strBuf).toString(); buffer.limit(limit); // Reset the limit return string; }
@Override protected int read(NioSession session, IoBuffer buf) throws Exception { ByteChannel channel = session.getChannel(); return channel.read(buf.buf()); }
@Override protected int send(NioSession session, IoBuffer buffer, SocketAddress remoteAddress) throws Exception { return ((DatagramChannel) session.getChannel()).send( buffer.buf(), remoteAddress); }
@Override public DecodingState decode(IoBuffer in, ProtocolDecoderOutput out) throws Exception { DerId id = DerId.decode(in.buf()); out.write(id); return READ_LENGTH; }
@Override protected int read(NioSession session, IoBuffer buf) throws Exception { ByteChannel channel = session.getChannel(); return channel.read(buf.buf()); }
@Override protected int send(NioSession session, IoBuffer buffer, SocketAddress remoteAddress) throws Exception { return ((DatagramChannel) session.getChannel()).send( buffer.buf(), remoteAddress); }
public void encode( IoSession session, Object message, ProtocolEncoderOutput out ) { IoBuffer buf = IoBuffer.allocate( 1024 ); encoder.encode( buf.buf(), ( DhcpMessage ) message ); buf.flip(); out.write( buf ); }
@Override protected int write(NioSession session, IoBuffer buf, int length) throws IOException { if (buf.remaining() <= length) { return session.getChannel().write(buf.buf()); } int oldLimit = buf.limit(); buf.limit(buf.position() + length); try { return session.getChannel().write(buf.buf()); } finally { buf.limit(oldLimit); } }
@Override protected DecodingState finishDecode(IoBuffer product, ProtocolDecoderOutput out) throws Exception { int t1 = product.getInt(); int t2 = product.getInt(); IoBuffer nonce = product.getSlice(NONCE_LENGTH); out.write(new RtmpHandshakeRequestMessage(t1, t2, nonce.buf())); return READ_CLIENT_HANDSHAKE_RESPONSE; } };
@Override protected DecodingState finishDecode(IoBuffer product, ProtocolDecoderOutput out) throws Exception { int t1 = product.getInt(); int t2 = product.getInt(); IoBuffer nonce = product.getSlice(NONCE_LENGTH); out.write(new RtmpHandshakeResponseMessage(t1, t2, nonce.buf())); return null; } };