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, extractFrame, 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
FrameDecoder.extractFrame(ChannelBuffer, int, int)method, to make optimizations easier later.
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-2014 The Netty Project. All Rights Reserved.