public abstract class ByteToMessageCodec<I> extends ChannelDuplexHandler
ByteToMessageDecoder
and MessageToByteEncoder
.
Be aware that sub-classes of ByteToMessageCodec
MUST NOT
annotated with @Sharable
.ChannelHandler.Sharable
限定符 | 构造器和说明 |
---|---|
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(java.lang.Class<? extends I> outboundMessageType)
see
ByteToMessageCodec(Class, boolean) with true as boolean value. |
protected |
ByteToMessageCodec(java.lang.Class<? extends I> outboundMessageType,
boolean preferDirect)
Create a new instance
|
限定符和类型 | 方法和说明 |
---|---|
boolean |
acceptOutboundMessage(java.lang.Object msg)
Returns
true if and only if the specified message can be encoded by this codec. |
void |
channelInactive(ChannelHandlerContext ctx)
Calls
ChannelHandlerContext.fireChannelInactive() to forward
to the next ChannelInboundHandler in the ChannelPipeline . |
void |
channelRead(ChannelHandlerContext ctx,
java.lang.Object msg)
Calls
ChannelHandlerContext.fireChannelRead(Object) to forward
to the next ChannelInboundHandler in the ChannelPipeline . |
void |
channelReadComplete(ChannelHandlerContext ctx)
Calls
ChannelHandlerContext.fireChannelReadComplete() to forward
to the next ChannelInboundHandler in the ChannelPipeline . |
protected abstract void |
decode(ChannelHandlerContext ctx,
ByteBuf in,
java.util.List<java.lang.Object> out) |
protected void |
decodeLast(ChannelHandlerContext ctx,
ByteBuf in,
java.util.List<java.lang.Object> out) |
protected abstract void |
encode(ChannelHandlerContext ctx,
I msg,
ByteBuf out) |
void |
handlerAdded(ChannelHandlerContext ctx)
Do nothing by default, sub-classes may override this method.
|
void |
handlerRemoved(ChannelHandlerContext ctx)
Do nothing by default, sub-classes may override this method.
|
void |
write(ChannelHandlerContext ctx,
java.lang.Object msg,
ChannelPromise promise)
Calls
ChannelHandlerContext.write(Object, ChannelPromise) to forward
to the next ChannelOutboundHandler in the ChannelPipeline . |
bind, close, connect, deregister, disconnect, flush, read
channelActive, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggered
ensureNotSharable, isSharable
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
exceptionCaught
protected ByteToMessageCodec()
ByteToMessageCodec(boolean)
with true
as boolean parameter.protected ByteToMessageCodec(java.lang.Class<? extends I> outboundMessageType)
ByteToMessageCodec(Class, boolean)
with true
as boolean value.protected ByteToMessageCodec(boolean preferDirect)
protected ByteToMessageCodec(java.lang.Class<? extends I> outboundMessageType, boolean preferDirect)
public boolean acceptOutboundMessage(java.lang.Object msg) throws java.lang.Exception
true
if and only if the specified message can be encoded by this codec.msg
- the messagejava.lang.Exception
public void channelRead(ChannelHandlerContext ctx, java.lang.Object msg) throws java.lang.Exception
ChannelInboundHandlerAdapter
ChannelHandlerContext.fireChannelRead(Object)
to forward
to the next ChannelInboundHandler
in the ChannelPipeline
.
Sub-classes may override this method to change behavior.channelRead
在接口中 ChannelInboundHandler
channelRead
在类中 ChannelInboundHandlerAdapter
java.lang.Exception
public void write(ChannelHandlerContext ctx, java.lang.Object msg, ChannelPromise promise) throws java.lang.Exception
ChannelDuplexHandler
ChannelHandlerContext.write(Object, ChannelPromise)
to forward
to the next ChannelOutboundHandler
in the ChannelPipeline
.
Sub-classes may override this method to change behavior.write
在接口中 ChannelOutboundHandler
write
在类中 ChannelDuplexHandler
ctx
- the ChannelHandlerContext
for which the write operation is mademsg
- the message to writepromise
- the ChannelPromise
to notify once the operation completesjava.lang.Exception
- thrown if an error occurspublic void channelReadComplete(ChannelHandlerContext ctx) throws java.lang.Exception
ChannelInboundHandlerAdapter
ChannelHandlerContext.fireChannelReadComplete()
to forward
to the next ChannelInboundHandler
in the ChannelPipeline
.
Sub-classes may override this method to change behavior.channelReadComplete
在接口中 ChannelInboundHandler
channelReadComplete
在类中 ChannelInboundHandlerAdapter
java.lang.Exception
public void channelInactive(ChannelHandlerContext ctx) throws java.lang.Exception
ChannelInboundHandlerAdapter
ChannelHandlerContext.fireChannelInactive()
to forward
to the next ChannelInboundHandler
in the ChannelPipeline
.
Sub-classes may override this method to change behavior.channelInactive
在接口中 ChannelInboundHandler
channelInactive
在类中 ChannelInboundHandlerAdapter
java.lang.Exception
public void handlerAdded(ChannelHandlerContext ctx) throws java.lang.Exception
ChannelHandlerAdapter
handlerAdded
在接口中 ChannelHandler
handlerAdded
在类中 ChannelHandlerAdapter
java.lang.Exception
public void handlerRemoved(ChannelHandlerContext ctx) throws java.lang.Exception
ChannelHandlerAdapter
handlerRemoved
在接口中 ChannelHandler
handlerRemoved
在类中 ChannelHandlerAdapter
java.lang.Exception
protected abstract void encode(ChannelHandlerContext ctx, I msg, ByteBuf out) throws java.lang.Exception
java.lang.Exception
MessageToByteEncoder.encode(ChannelHandlerContext, Object, ByteBuf)
protected abstract void decode(ChannelHandlerContext ctx, ByteBuf in, java.util.List<java.lang.Object> out) throws java.lang.Exception
java.lang.Exception
ByteToMessageDecoder.decode(ChannelHandlerContext, ByteBuf, List)
protected void decodeLast(ChannelHandlerContext ctx, ByteBuf in, java.util.List<java.lang.Object> out) throws java.lang.Exception
java.lang.Exception
ByteToMessageDecoder.decodeLast(ChannelHandlerContext, ByteBuf, List)