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()
see
ByteToMessageCodec(boolean) with true as boolean parameter. |
protected |
ByteToMessageCodec(boolean preferDirect)
Create a new instance which will try to detect the types to match out of the type parameter of the class.
|
protected |
ByteToMessageCodec(Class<? extends I> outboundMessageType)
see
ByteToMessageCodec(Class, boolean) with true as boolean value. |
protected |
ByteToMessageCodec(Class<? extends I> outboundMessageType,
boolean preferDirect)
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 |
channelInactive(io.netty.channel.ChannelHandlerContext ctx) |
void |
channelRead(io.netty.channel.ChannelHandlerContext ctx,
Object msg) |
void |
channelReadComplete(io.netty.channel.ChannelHandlerContext ctx) |
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 |
handlerAdded(io.netty.channel.ChannelHandlerContext ctx) |
void |
handlerRemoved(io.netty.channel.ChannelHandlerContext ctx) |
void |
write(io.netty.channel.ChannelHandlerContext ctx,
Object msg,
io.netty.channel.ChannelPromise promise) |
bind, close, connect, deregister, disconnect, flush, readchannelActive, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggeredprotected ByteToMessageCodec()
ByteToMessageCodec(boolean) with true as boolean parameter.protected ByteToMessageCodec(Class<? extends I> outboundMessageType)
ByteToMessageCodec(Class, boolean) with true as boolean value.protected ByteToMessageCodec(boolean preferDirect)
preferDirect - true if a direct ByteBuf should be tried to be used as target for
the encoded messages. If false is used it will allocate a heap
ByteBuf, which is backed by an byte array.protected ByteToMessageCodec(Class<? extends I> outboundMessageType, boolean preferDirect)
outboundMessageType - The type of messages to matchpreferDirect - true if a direct ByteBuf should be tried to be used as target for
the encoded messages. If false is used it will allocate a heap
ByteBuf, which is backed by an byte array.public boolean acceptOutboundMessage(Object msg) throws Exception
true if and only if the specified message can be encoded by this codec.msg - the messageExceptionpublic void channelRead(io.netty.channel.ChannelHandlerContext ctx,
Object msg)
throws Exception
channelRead in interface io.netty.channel.ChannelInboundHandlerchannelRead in class io.netty.channel.ChannelInboundHandlerAdapterExceptionpublic void write(io.netty.channel.ChannelHandlerContext ctx,
Object msg,
io.netty.channel.ChannelPromise promise)
throws Exception
write in interface io.netty.channel.ChannelOutboundHandlerwrite in class io.netty.channel.ChannelDuplexHandlerExceptionpublic void channelReadComplete(io.netty.channel.ChannelHandlerContext ctx)
throws Exception
channelReadComplete in interface io.netty.channel.ChannelInboundHandlerchannelReadComplete in class io.netty.channel.ChannelInboundHandlerAdapterExceptionpublic void channelInactive(io.netty.channel.ChannelHandlerContext ctx)
throws Exception
channelInactive in interface io.netty.channel.ChannelInboundHandlerchannelInactive in class io.netty.channel.ChannelInboundHandlerAdapterExceptionpublic void handlerAdded(io.netty.channel.ChannelHandlerContext ctx)
throws Exception
handlerAdded in interface io.netty.channel.ChannelHandlerhandlerAdded in class io.netty.channel.ChannelHandlerAdapterExceptionpublic void handlerRemoved(io.netty.channel.ChannelHandlerContext ctx)
throws Exception
handlerRemoved in interface io.netty.channel.ChannelHandlerhandlerRemoved in class io.netty.channel.ChannelHandlerAdapterExceptionprotected abstract void encode(io.netty.channel.ChannelHandlerContext ctx,
I msg,
io.netty.buffer.ByteBuf out)
throws Exception
ExceptionMessageToByteEncoder.encode(ChannelHandlerContext, Object, ByteBuf)protected abstract void decode(io.netty.channel.ChannelHandlerContext ctx,
io.netty.buffer.ByteBuf in,
List<Object> out)
throws Exception
ExceptionByteToMessageDecoder.decode(ChannelHandlerContext, ByteBuf, List)Copyright © 2008–2019 The Netty Project. All rights reserved.