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
(3)will decode them into the following three packets with the fixed length:
+-----+-----+-----+ | ABC | DEF | GHI | +-----+-----+-----+
|Constructor and Description|
Creates a new instance.
|Modifier and Type||Method and Description|
Decodes the received packets so far into a frame.
Create a new
actualReadableBytes, afterAdd, afterRemove, appendToCumulation, beforeAdd, beforeRemove, channelClosed, channelDisconnected, cleanup, decodeLast, exceptionCaught, getMaxCumulationBufferCapacity, getMaxCumulationBufferComponents, internalBuffer, isUnfold, messageReceived, replace, setMaxCumulationBufferCapacity, setMaxCumulationBufferComponents, setUnfold, unfoldAndFireMessageReceived, updateCumulation
channelBound, channelConnected, channelInterestChanged, channelOpen, channelUnbound, childChannelClosed, childChannelOpen, handleUpstream, writeComplete
public FixedLengthFrameDecoder(int frameLength)
protected Object decode(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer) throws Exception
ctx- the context of this handler
channel- the current channel
buffer- 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.
nullif there's not enough data in the buffer to decode a frame.
protected ChannelBuffer newCumulationBuffer(ChannelHandlerContext ctx, int minimumCapacity)
ChannelBufferwhich is used for the cumulation. Sub-classes may override this.
Copyright © 2008-2013 The Netty Project. All Rights Reserved.