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

public Class ByteArrayDecoder

extends MessageToMessageDecoder<ByteBuf>
Class Inheritance
Imports
io.netty.buffer.ByteBuf, .ByteBufUtil, io.netty.channel.ChannelHandlerContext, .ChannelPipeline, io.netty.handler.codec.LengthFieldBasedFrameDecoder, .LengthFieldPrepender, .MessageToMessageDecoder, java.util.List

Decodes a received ByteBuf 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 ByteBuf 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, ByteBuf
the message to decode to an other one
msg
,
List<Object>
the List to which decoded messages should be added
out
)

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

Decode from one message to an other.
Inherited from io.netty.handler.codec.MessageToMessageDecoder:
acceptInboundMessagechannelRead

Constructor Detail

ByteArrayDecoderback to summary
public ByteArrayDecoder()

Method Detail

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

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

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

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

Parameters
ctx:ChannelHandlerContext

the ChannelHandlerContext which this MessageToMessageDecoder belongs to

msg:ByteBuf

the message to decode to an other one

out:List<Object>

the List to which decoded messages should be added

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