public class FixedLengthFrameDecoder extends ByteToMessageDecoder
ByteBufs by the fixed number
of bytes. For example, if you received the following four fragmented packets:
+---+----+------+----+ | A | BC | DEFG | HI | +---+----+------+----+A
FixedLengthFrameDecoder(3) will decode them into the
following three packets with the fixed length:
+-----+-----+-----+ | ABC | DEF | GHI | +-----+-----+-----+
| Constructor and Description |
|---|
FixedLengthFrameDecoder(int frameLength)
Calls
FixedLengthFrameDecoder(int, boolean) with false |
FixedLengthFrameDecoder(int frameLength,
boolean allocateFullBuffer)
Creates a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
protected Object |
decode(io.netty.channel.ChannelHandlerContext ctx,
io.netty.buffer.ByteBuf in)
Decode the from one
ByteBuf to an other. |
io.netty.buffer.ByteBuf |
newInboundBuffer(io.netty.channel.ChannelHandlerContext ctx) |
callDecode, channelInactive, channelReadSuspended, decodeLast, inboundBufferUpdated, isSingleDecode, setSingleDecodediscardInboundReadBytes, freeInboundBuffer, inboundBufferUpdatedchannelActive, channelRegistered, channelUnregistered, userEventTriggeredafterAdd, afterRemove, beforeAdd, beforeRemove, exceptionCaughtclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitpublic FixedLengthFrameDecoder(int frameLength)
FixedLengthFrameDecoder(int, boolean) with falsepublic FixedLengthFrameDecoder(int frameLength,
boolean allocateFullBuffer)
frameLength - the length of the frameallocateFullBuffer - true if the cumulative ByteBuf should use the
frameLength as its initial sizepublic io.netty.buffer.ByteBuf newInboundBuffer(io.netty.channel.ChannelHandlerContext ctx)
throws Exception
newInboundBuffer in interface io.netty.channel.ChannelInboundByteHandlernewInboundBuffer in class io.netty.channel.ChannelInboundByteHandlerAdapterExceptionprotected Object decode(io.netty.channel.ChannelHandlerContext ctx, io.netty.buffer.ByteBuf in) throws Exception
ByteToMessageDecoderByteBuf to an other. This method will be called till either the input
ByteBuf has nothing to read anymore, till nothing was read from the input ByteBuf or till
this method returns null.decode in class ByteToMessageDecoderctx - the ChannelHandlerContext which this ByteToByteDecoder belongs toin - the ByteBuf from which to read dataByteBuf was decoded, or null if
there was not enough data left in the ByteBuf to decode.Exception - is thrown if an error accourCopyright © 2008-2013 The Netty Project. All Rights Reserved.