
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 | +-----+-----+-----+
| Constructor and Description |
|---|
FixedLengthFrameDecoder(int frameLength)
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.
|
channelClosed, channelDisconnected, decodeLast, exceptionCaught, messageReceivedchannelBound, channelConnected, channelInterestChanged, channelOpen, channelUnbound, childChannelClosed, childChannelOpen, handleUpstream, writeCompletepublic FixedLengthFrameDecoder(int frameLength)
frameLength - the length of the frameprotected Object decode(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer) throws Exception
FrameDecoderdecode 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.ExceptionCopyright © 2008-2013 JBoss, by Red Hat. All Rights Reserved.