public class FixedLengthFrameDecoder extends FrameDecoder
ChannelBuffer
s 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.Sharable
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, messageReceived
channelBound, channelConnected, channelInterestChanged, channelOpen, channelUnbound, childChannelClosed, childChannelOpen, handleUpstream, writeComplete
public FixedLengthFrameDecoder(int frameLength)
frameLength
- the length of the frameprotected Object decode(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer) throws Exception
FrameDecoder
decode
in class FrameDecoder
ctx
- 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.Exception
Copyright © 2008-2012 JBoss, a division of Red Hat, Inc.. All Rights Reserved.