Top Description Fields Constructors Methods
io.netty.handler.codec

public Class FixedLengthFrameDecoder

extends ByteToMessageDecoder
Class Inheritance
Static Imports
io.netty.util.internal.ObjectUtil.checkPositive

A decoder that splits the received ByteBufs 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 |
+-----+-----+-----+

Field Summary

Modifier and TypeField and Description
private final int
Inherited from io.netty.handler.codec.ByteToMessageDecoder:
COMPOSITE_CUMULATORcumulationMERGE_CUMULATOR

Constructor Summary

AccessConstructor and Description
public
FixedLengthFrameDecoder(int
the length of the frame
frameLength
)

Creates a new instance.

Method Summary

Modifier and TypeMethod and Description
protected final void
decode(ChannelHandlerContext ctx, ByteBuf
the ByteBuf from which to read data
in
,
List<Object>
the List to which decoded messages should be added
out
)

Implements abstract io.netty.handler.codec.ByteToMessageDecoder.decode.

Decode the from one ByteBuf to an other.
protected Object

Returns:

frame the ByteBuf which represent the frame or null if no frame could be created.
decode
(ChannelHandlerContext ctx, ByteBuf
the ByteBuf from which to read data
in
)

Create a frame out of the ByteBuf and return it.

Inherited from io.netty.handler.codec.ByteToMessageDecoder:
actualReadableBytescallDecodechannelInactivechannelInputClosedchannelReadchannelReadCompletedecodeLastdecodeRemovalReentryProtectiondiscardSomeReadBytesexpandCumulationfireChannelReadfireChannelReadhandlerRemovedhandlerRemoved0internalBufferisSingleDecodesetCumulatorsetDiscardAfterReadssetSingleDecodeuserEventTriggered

Field Detail

frameLengthback to summary
private final int frameLength

Constructor Detail

FixedLengthFrameDecoderback to summary
public FixedLengthFrameDecoder(int frameLength)

Creates a new instance.

Parameters
frameLength:int

the length of the frame

Method Detail

decodeback to summary
protected final void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception

Implements abstract io.netty.handler.codec.ByteToMessageDecoder.decode.

Doc from io.netty.handler.codec.ByteToMessageDecoder.decode.

Decode the from one ByteBuf to an other. This method will be called till either the input ByteBuf has nothing to read when return from this method or till nothing was read from the input ByteBuf.

Parameters
ctx:ChannelHandlerContext

the ChannelHandlerContext which this ByteToMessageDecoder belongs to

in:ByteBuf

the ByteBuf from which to read data

out:List<Object>

the List to which decoded messages should be added

Annotations
@Override
Exceptions
Exception:
is thrown if an error occurs
decodeback to summary
protected Object decode(ChannelHandlerContext ctx, ByteBuf in) throws Exception

Create a frame out of the ByteBuf and return it.

Parameters
ctx:ChannelHandlerContext

the ChannelHandlerContext which this ByteToMessageDecoder belongs to

in:ByteBuf

the ByteBuf from which to read data

Returns:Object

frame the ByteBuf which represent the frame or null if no frame could be created.