public abstract class MessageToMessageEncoder<I>
extends io.netty.channel.ChannelOutboundMessageHandlerAdapter<I>
ChannelOutboundMessageHandlerAdapter
which encodes from one message to an other message
For example here is an implementation which decodes an Integer
to an String
.
public class IntegerToStringEncoder extendsMessageToMessageEncoder
<Integer
> {@Override
public void encode(ChannelHandlerContext
ctx,Integer
message,MessageBuf
out) throwsException
{ out.add(message.toString()); } }
Modifier | Constructor and Description |
---|---|
protected |
MessageToMessageEncoder() |
protected |
MessageToMessageEncoder(Class<? extends I> outboundMessageType) |
Modifier and Type | Method and Description |
---|---|
protected abstract void |
encode(io.netty.channel.ChannelHandlerContext ctx,
I msg,
io.netty.buffer.MessageBuf<Object> out)
Encode from one message to an other.
|
void |
flush(io.netty.channel.ChannelHandlerContext ctx,
I 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
public final void flush(io.netty.channel.ChannelHandlerContext ctx, I msg) throws Exception
Exception
protected abstract void encode(io.netty.channel.ChannelHandlerContext ctx, I msg, io.netty.buffer.MessageBuf<Object> out) throws Exception
MessageBuf
has nothing
left or till this method returns null
.ctx
- the ChannelHandlerContext
which this MessageToMessageEncoder
belongs tomsg
- the message to encode to an other oneout
- the MessageBuf
into which the encoded msg should be added
needs to do some kind of aggragationException
- is thrown if an error accourCopyright © 2008-2013 The Netty Project. All Rights Reserved.