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

public Class ByteArrayDecoder

extends MessageToMessageDecoder<Buffer>
Class Inheritance
Imports
io.netty5.buffer.Buffer, io.netty5.channel.ChannelHandlerContext, .ChannelPipeline, io.netty5.handler.codec.LengthFieldPrepender, .MessageToMessageDecoder

Decodes a received Buffer into an array of bytes. A typical setup for TCP/IP would be:
ChannelPipeline pipeline = ...;

// Decoders
pipeline.addLast("frameDecoder",
                 new LengthFieldBasedFrameDecoder(1048576, 0, 4, 0, 4));
pipeline.addLast("bytesDecoder",
                 new ByteArrayDecoder());

// Encoder
pipeline.addLast("frameEncoder", new LengthFieldPrepender(4));
pipeline.addLast("bytesEncoder", new ByteArrayEncoder());
and then you can use an array of bytes instead of a Buffer as a message:
void channelRead(ChannelHandlerContext ctx, byte[] bytes) {
    ...
}

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected void
decode(ChannelHandlerContext ctx, Buffer
the message to decode to another one
msg
)

Overrides io.netty5.handler.codec.MessageToMessageDecoder.decode.

Decode from one message to another.
Inherited from io.netty5.handler.codec.MessageToMessageDecoder:
acceptInboundMessagechannelReaddecodeAndClose

Constructor Detail

ByteArrayDecoderback to summary
public ByteArrayDecoder()

Method Detail

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

Overrides io.netty5.handler.codec.MessageToMessageDecoder.decode.

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

Decode from one message to another. This method will be called for each written message that can be handled by this decoder.

The message will be disposed of after this call.

Subclasses that wish to sometimes pass messages through, should instead override the decodeAndClose(ChannelHandlerContext, Object) method.

Parameters
ctx:ChannelHandlerContext

the ChannelHandlerContext which this MessageToMessageDecoder belongs to

msg:Buffer

the message to decode to another one

Annotations
@Override
Exceptions
Exception:
is thrown if an error occurs