public abstract class ByteToMessageCodec<I>
extends io.netty.channel.ChannelDuplexHandler
ByteToMessageDecoder
and MessageToByteEncoder
.
Be aware that sub-classes of ByteToMessageCodec
MUST NOT
annotated with @Sharable
.Modifier | Constructor and Description |
---|---|
protected |
ByteToMessageCodec()
Create a new instance which will try to detect the types to encode out of the type parameter
of the class.
|
protected |
ByteToMessageCodec(Class<? extends I> outboundMessageType)
Create a new instance.
|
Modifier and Type | Method and Description |
---|---|
boolean |
acceptOutboundMessage(Object msg)
Returns
true if and only if the specified message can be encoded by this codec. |
void |
channelRead(io.netty.channel.ChannelHandlerContext ctx,
Object msg) |
protected abstract void |
decode(io.netty.channel.ChannelHandlerContext ctx,
io.netty.buffer.ByteBuf in,
List<Object> out) |
protected void |
decodeLast(io.netty.channel.ChannelHandlerContext ctx,
io.netty.buffer.ByteBuf in,
List<Object> out) |
protected abstract void |
encode(io.netty.channel.ChannelHandlerContext ctx,
I msg,
io.netty.buffer.ByteBuf out) |
void |
write(io.netty.channel.ChannelHandlerContext ctx,
Object msg,
io.netty.channel.ChannelPromise promise) |
bind, close, connect, deregister, disconnect, flush, read
channelActive, channelInactive, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, userEventTriggered
exceptionCaught, handlerAdded, handlerRemoved
protected ByteToMessageCodec()
public boolean acceptOutboundMessage(Object msg) throws Exception
true
if and only if the specified message can be encoded by this codec.msg
- the messageException
public void channelRead(io.netty.channel.ChannelHandlerContext ctx, Object msg) throws Exception
channelRead
in interface io.netty.channel.ChannelInboundHandler
channelRead
in class io.netty.channel.ChannelInboundHandlerAdapter
Exception
public void write(io.netty.channel.ChannelHandlerContext ctx, Object msg, io.netty.channel.ChannelPromise promise) throws Exception
write
in interface io.netty.channel.ChannelOutboundHandler
write
in class io.netty.channel.ChannelDuplexHandler
Exception
protected abstract void encode(io.netty.channel.ChannelHandlerContext ctx, I msg, io.netty.buffer.ByteBuf out) throws Exception
protected abstract void decode(io.netty.channel.ChannelHandlerContext ctx, io.netty.buffer.ByteBuf in, List<Object> out) throws Exception
Copyright © 2008–2013 The Netty Project. All rights reserved.