public class FixedLengthFrameDecoder extends FrameDecoder
ChannelBuffers 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 | +-----+-----+-----+
ChannelHandler.Sharablecumulation, DEFAULT_MAX_COMPOSITEBUFFER_COMPONENTS| 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(ChannelHandlerContext ctx,
Channel channel,
ChannelBuffer buffer)
Decodes the received packets so far into a frame.
|
protected ChannelBuffer |
newCumulationBuffer(ChannelHandlerContext ctx,
int minimumCapacity)
Create a new
ChannelBuffer which is used for the cumulation. |
actualReadableBytes, afterAdd, afterRemove, appendToCumulation, beforeAdd, beforeRemove, channelClosed, channelDisconnected, cleanup, decodeLast, exceptionCaught, extractFrame, getMaxCumulationBufferCapacity, getMaxCumulationBufferComponents, internalBuffer, isUnfold, messageReceived, replace, setMaxCumulationBufferCapacity, setMaxCumulationBufferComponents, setUnfold, unfoldAndFireMessageReceived, updateCumulationchannelBound, channelConnected, channelInterestChanged, channelOpen, channelUnbound, childChannelClosed, childChannelOpen, handleUpstream, writeCompletepublic FixedLengthFrameDecoder(int frameLength)
FixedLengthFrameDecoder(int, boolean) with falsepublic FixedLengthFrameDecoder(int frameLength,
boolean allocateFullBuffer)
frameLength - the length of the frameallocateFullBuffer - true if the cumulative ChannelBuffer should use the
frameLength as its initial sizeprotected Object decode(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer) throws Exception
FrameDecoderFrameDecoder.extractFrame(ChannelBuffer, int, int) method,
to make optimizations easier later.decode in class FrameDecoderctx - the context of this handlerchannel - the current channelbuffer - the cumulative buffer of received packets so far.
Note that the buffer might be empty, which means you
should not make an assumption that the buffer contains
at least one byte in your decoder implementation.null if there's not enough data in the buffer to decode a frame.Exceptionprotected ChannelBuffer newCumulationBuffer(ChannelHandlerContext ctx, int minimumCapacity)
FrameDecoderChannelBuffer which is used for the cumulation.
Sub-classes may override this.newCumulationBuffer in class FrameDecoderctx - ChannelHandlerContext for this handlerChannelBuffer which is used for cumulationCopyright © 2008-2016 The Netty Project. All Rights Reserved.