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

public Class FixedLengthFrameDecoder

extends ByteToMessageDecoder
Class Inheritance
Imports
io.netty5.buffer.Buffer, io.netty5.channel.ChannelHandlerContext

A decoder that splits the received Buffers 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.netty5.handler.codec.ByteToMessageDecoder:
COMPOSITE_CUMULATORMERGE_CUMULATOR

Constructor Summary

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

Creates a new instance.

public
FixedLengthFrameDecoder(int
the length of the frame
frameLength
,
ByteToMessageDecoder.Cumulator cumulator)

Creates a new instance.

Method Summary

Modifier and TypeMethod and Description
protected final void
decode(ChannelHandlerContext ctx, Buffer
the Buffer from which to read data
in
)

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

Decode the from one Buffer to another.
protected Object

Returns:

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

Create a frame out of the Buffer and return it.

Inherited from io.netty5.handler.codec.ByteToMessageDecoder:
actualReadableBytescallDecodechannelInactivechannelInputClosedchannelReadchannelReadCompletechannelShutdowndecodeLastdecodeRemovalReentryProtectiondiscardSomeReadByteshandlerAddedhandlerAdded0handlerRemovedhandlerRemoved0internalBufferisSharableisSingleDecodesetSingleDecode

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

FixedLengthFrameDecoderback to summary
public FixedLengthFrameDecoder(int frameLength, ByteToMessageDecoder.Cumulator cumulator)

Creates a new instance.

Parameters
frameLength:int

the length of the frame

Method Detail

decodeback to summary
protected final void decode(ChannelHandlerContext ctx, Buffer in) throws Exception

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

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

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

Parameters
ctx:ChannelHandlerContext

the ChannelHandlerContext which this ByteToMessageDecoder belongs to

in:Buffer

the Buffer from which to read data

Annotations
@Override
Exceptions
Exception:
is thrown if an error occurs
decode0back to summary
protected Object decode0(ChannelHandlerContext ctx, Buffer in) throws Exception

Create a frame out of the Buffer and return it.

Parameters
ctx:ChannelHandlerContext

the ChannelHandlerContext which this ByteToMessageDecoder belongs to

in:Buffer

the Buffer from which to read data

Returns:Object

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