public abstract class MessageToMessageDecoder<I>
extends io.netty.channel.ChannelInboundMessageHandlerAdapter<I>
ChannelInboundMessageHandler
which decodes from one message to an other message
For example here is an implementation which decodes a String
to an Integer
which represent
the length of the String
.
public class StringToIntegerDecoder extendsMessageToMessageDecoder
<String
> {@Override
public void decode(ChannelHandlerContext
ctx,String
message,MessageBuf
out) throwsException
{ out.add(message.length()); } }
Modifier | Constructor and Description |
---|---|
protected |
MessageToMessageDecoder() |
protected |
MessageToMessageDecoder(Class<? extends I> inboundMessageType) |
Modifier and Type | Method and Description |
---|---|
protected abstract void |
decode(io.netty.channel.ChannelHandlerContext ctx,
I msg,
io.netty.buffer.MessageBuf<Object> out)
Decode from one message to an other.
|
void |
messageReceived(io.netty.channel.ChannelHandlerContext ctx,
I msg) |
acceptInboundMessage, beginMessageReceived, endMessageReceived, inboundBufferUpdated, newInboundBuffer
channelActive, channelInactive, channelReadSuspended, channelRegistered, channelUnregistered, userEventTriggered
exceptionCaught, handlerAdded, handlerRemoved
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
public final void messageReceived(io.netty.channel.ChannelHandlerContext ctx, I msg) throws Exception
Exception
protected abstract void decode(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 MessageToMessageDecoder
belongs tomsg
- the message to decode to an other oneout
- the MessageBuf
to which decoded messages should be addedException
- is thrown if an error accourCopyright © 2008-2013 The Netty Project. All Rights Reserved.