@ChannelHandler.Sharable
public class ByteArrayEncoder
extends io.netty.channel.ChannelOutboundMessageHandlerAdapter<byte[]>
ByteBuf
.
A typical setup for TCP/IP would be:
and then you can use an array of bytes instead of aChannelPipeline
pipeline = ...; // 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(ChannelHandlerContext
ctx, byte[] bytes) {
...
}
Constructor and Description |
---|
ByteArrayEncoder() |
Modifier and Type | Method and Description |
---|---|
void |
flush(io.netty.channel.ChannelHandlerContext ctx,
byte[] msg) |
acceptOutboundMessage, beginFlush, endFlush, flush, isCloseOnFailedFlush, newOutboundBuffer, setCloseOnFailedFlush
bind, close, connect, deregister, disconnect, read, sendFile
exceptionCaught, handlerAdded, handlerRemoved
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Copyright © 2008-2013 The Netty Project. All Rights Reserved.