public abstract class MessageToByteEncoder<I>
extends io.netty.channel.ChannelOutboundMessageHandlerAdapter<I>
ChannelOutboundMessageHandlerAdapter which encodes message in a stream-like fashion from one message to an
ByteBuf.
Example implementation which encodes Integers to a ByteBuf.
public class IntegerEncoder extends MessageToByteEncoder<Integer> {
@Override
public void encode(ChannelHandlerContext ctx, Integer msg, ByteBuf out)
throws Exception {
out.writeInt(msg);
}
}
| Constructor and Description |
|---|
MessageToByteEncoder() |
| Modifier and Type | Method and Description |
|---|---|
protected abstract void |
encode(io.netty.channel.ChannelHandlerContext ctx,
I msg,
io.netty.buffer.ByteBuf out)
Encode a message into a
ByteBuf. |
void |
flush(io.netty.channel.ChannelHandlerContext ctx,
I msg) |
acceptOutboundMessage, beginFlush, endFlush, flush, freeOutboundBuffer, isCloseOnFailedFlush, newOutboundBuffer, setCloseOnFailedFlushbind, close, connect, deregister, disconnect, read, sendFileafterAdd, afterRemove, beforeAdd, beforeRemove, exceptionCaughtclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitpublic void flush(io.netty.channel.ChannelHandlerContext ctx,
I msg)
throws Exception
Exceptionprotected abstract void encode(io.netty.channel.ChannelHandlerContext ctx,
I msg,
io.netty.buffer.ByteBuf out)
throws Exception
ByteBuf. This method will be called till the MessageBuf has
nothing left.ctx - the ChannelHandlerContext which this MessageToByteEncoder belongs tomsg - the message to encodeout - the ByteBuf into which the encoded message will be writtenException - is thrown if an error accourCopyright © 2008-2013 The Netty Project. All Rights Reserved.