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, read
channelActive, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggered
protected 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 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
public void channelReadComplete(io.netty.channel.ChannelHandlerContext ctx) throws Exception
channelReadComplete
in interface io.netty.channel.ChannelInboundHandler
channelReadComplete
in class io.netty.channel.ChannelInboundHandlerAdapter
Exception
public void channelInactive(io.netty.channel.ChannelHandlerContext ctx) throws Exception
channelInactive
in interface io.netty.channel.ChannelInboundHandler
channelInactive
in class io.netty.channel.ChannelInboundHandlerAdapter
Exception
public void handlerAdded(io.netty.channel.ChannelHandlerContext ctx) throws Exception
handlerAdded
in interface io.netty.channel.ChannelHandler
handlerAdded
in class io.netty.channel.ChannelHandlerAdapter
Exception
public void handlerRemoved(io.netty.channel.ChannelHandlerContext ctx) throws Exception
handlerRemoved
in interface io.netty.channel.ChannelHandler
handlerRemoved
in class io.netty.channel.ChannelHandlerAdapter
Exception
protected abstract void encode(io.netty.channel.ChannelHandlerContext ctx, I msg, io.netty.buffer.ByteBuf out) throws Exception
Exception
MessageToByteEncoder.encode(ChannelHandlerContext, Object, ByteBuf)
protected abstract void decode(io.netty.channel.ChannelHandlerContext ctx, io.netty.buffer.ByteBuf in, List<Object> out) throws Exception
Exception
ByteToMessageDecoder.decode(ChannelHandlerContext, ByteBuf, List)
Copyright © 2008–2019 The Netty Project. All rights reserved.