public abstract class ByteToMessageCodec<I> extends ChannelDuplexHandler
ByteToMessageDecoder and MessageToByteEncoder.
Be aware that sub-classes of ByteToMessageCodec MUST NOT
annotated with @Sharable.ChannelHandler.Sharable| Modifier | Constructor and Description |
|---|---|
protected |
ByteToMessageCodec() |
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) |
protected |
ByteToMessageCodec(Class<? extends I> outboundMessageType,
boolean preferDirect)
Create a new instance
|
bind, close, connect, deregister, disconnect, flush, readchannelActive, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggeredisSharableclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitexceptionCaughtprotected ByteToMessageCodec()
#ByteToMessageCodec(boolean)} with {@code true} as boolean parameter.protected ByteToMessageCodec(Class<? extends I> outboundMessageType)
#ByteToMessageCodec(Class, boolean)} with {@code true} as boolean value.protected ByteToMessageCodec(boolean preferDirect)
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(ChannelHandlerContext ctx, Object msg) throws Exception
ChannelInboundHandlerAdapterChannelHandlerContext.fireChannelRead(Object) to forward
to the next ChannelInboundHandler in the ChannelPipeline.
Sub-classes may override this method to change behavior.channelRead in interface ChannelInboundHandlerchannelRead in class ChannelInboundHandlerAdapterExceptionpublic void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception
ChannelDuplexHandlerChannelHandlerContext.write(Object, ChannelPromise) to forward
to the next ChannelOutboundHandler in the ChannelPipeline.
Sub-classes may override this method to change behavior.write in interface ChannelOutboundHandlerwrite in class ChannelDuplexHandlerctx - the ChannelHandlerContext for which the write operation is mademsg - the message to writepromise - the ChannelPromise to notify once the operation completesException - thrown if an error accourpublic void channelReadComplete(ChannelHandlerContext ctx) throws Exception
ChannelInboundHandlerAdapterChannelHandlerContext.fireChannelReadComplete() to forward
to the next ChannelInboundHandler in the ChannelPipeline.
Sub-classes may override this method to change behavior.channelReadComplete in interface ChannelInboundHandlerchannelReadComplete in class ChannelInboundHandlerAdapterExceptionpublic void channelInactive(ChannelHandlerContext ctx) throws Exception
ChannelInboundHandlerAdapterChannelHandlerContext.fireChannelInactive() to forward
to the next ChannelInboundHandler in the ChannelPipeline.
Sub-classes may override this method to change behavior.channelInactive in interface ChannelInboundHandlerchannelInactive in class ChannelInboundHandlerAdapterExceptionpublic void handlerAdded(ChannelHandlerContext ctx) throws Exception
ChannelHandlerAdapterhandlerAdded in interface ChannelHandlerhandlerAdded in class ChannelHandlerAdapterExceptionpublic void handlerRemoved(ChannelHandlerContext ctx) throws Exception
ChannelHandlerAdapterhandlerRemoved in interface ChannelHandlerhandlerRemoved in class ChannelHandlerAdapterExceptionprotected abstract void encode(ChannelHandlerContext ctx, I msg, ByteBuf out) throws Exception
protected abstract void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception
protected void decodeLast(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception
Copyright © 2008–2016 The Netty Project. All rights reserved.