public class ByteArrayDecoder extends MessageToMessageDecoder<io.netty.buffer.ByteBuf,byte[]>
ByteBuf into an array of bytes.
A typical setup for TCP/IP would be:
and then you can use an array of bytes instead of aChannelPipelinepipeline = ...; // Decoders pipeline.addLast("frameDecoder", newLengthFieldBasedFrameDecoder(1048576, 0, 4, 0, 4)); pipeline.addLast("bytesDecoder", newByteArrayDecoder()); // Encoder pipeline.addLast("frameEncoder", newLengthFieldPrepender(4)); pipeline.addLast("bytesEncoder", newByteArrayEncoder());
ByteBuf
as a message:
void messageReceived(ChannelHandlerContextctx,MessageEvente) { byte[] bytes = (byte[]) e.getMessage(); ... }
| Constructor and Description |
|---|
ByteArrayDecoder() |
| Modifier and Type | Method and Description |
|---|---|
byte[] |
decode(io.netty.channel.ChannelHandlerContext ctx,
io.netty.buffer.ByteBuf msg) |
inboundBufferUpdated, isDecodable, newInboundBufferafterAdd, afterRemove, beforeAdd, beforeRemove, channelActive, channelInactive, channelRegistered, channelUnregistered, exceptionCaught, userEventTriggeredclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitpublic byte[] decode(io.netty.channel.ChannelHandlerContext ctx,
io.netty.buffer.ByteBuf msg)
throws Exception
decode in class MessageToMessageDecoder<io.netty.buffer.ByteBuf,byte[]>ExceptionCopyright © 2008-2012 The Netty Project. All Rights Reserved.