public abstract class ByteToMessageCodec<I> extends ChannelDuplexHandler
ByteToMessageDecoder和MessageToByteEncoder的组合。
请注意, ByteToMessageCodec的子类不能用@Sharable注释。
ChannelHandler.Sharable| Modifier | Constructor and Description |
|---|---|
protected |
ByteToMessageCodec()
参见
ByteToMessageCodec(boolean)和
true作为布尔参数。
|
protected |
ByteToMessageCodec(boolean preferDirect)
创建一个新实例,它将尝试检测类型以匹配该类的类型参数。
|
protected |
ByteToMessageCodec(java.lang.Class<? extends I> outboundMessageType)
参见
ByteToMessageCodec(Class, boolean)和
true作为布尔值。
|
protected |
ByteToMessageCodec(java.lang.Class<? extends I> outboundMessageType, boolean preferDirect)
创建一个新的实例
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
acceptOutboundMessage(java.lang.Object msg)
当且仅当指定的消息可以由此编解码器编码时返回
true 。
|
void |
channelInactive(ChannelHandlerContext ctx)
|
void |
channelRead(ChannelHandlerContext ctx, java.lang.Object msg)
|
void |
channelReadComplete(ChannelHandlerContext ctx)
|
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)
子类可以忽略这个方法。
|
void |
handlerRemoved(ChannelHandlerContext ctx)
子类可以忽略这个方法。
|
void |
write(ChannelHandlerContext ctx, java.lang.Object msg, ChannelPromise promise)
|
bind, close, connect, deregister, disconnect, flush, readchannelActive, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggeredensureNotSharable, isSharableclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitexceptionCaughtprotected ByteToMessageCodec()
ByteToMessageCodec(boolean)和
true作为布尔参数。
protected ByteToMessageCodec(java.lang.Class<? extends I> outboundMessageType)
ByteToMessageCodec(Class, boolean)和
true作为布尔值。
protected ByteToMessageCodec(boolean preferDirect)
public boolean acceptOutboundMessage(java.lang.Object msg)
throws java.lang.Exception
true 。
msg - 消息
java.lang.Exception
public void channelRead(ChannelHandlerContext ctx, java.lang.Object msg) throws java.lang.Exception
ChannelInboundHandlerAdapter
ChannelHandlerContext.fireChannelRead(Object)转发到ChannelPipeline中的下一个ChannelInboundHandler 。
子类可以重写此方法来更改行为。
channelRead在界面
ChannelInboundHandler
channelRead在课堂上
ChannelInboundHandlerAdapter
java.lang.Exception
public void write(ChannelHandlerContext ctx, java.lang.Object msg, ChannelPromise promise) throws java.lang.Exception
ChannelDuplexHandler
ChannelOutboundInvoker.write(Object, ChannelPromise)转发到ChannelPipeline中的下一个ChannelOutboundHandler 。
子类可以重写此方法来更改行为。
write ,界面
ChannelOutboundHandler
write ,课时
ChannelDuplexHandler
ctx - 为其写入操作的ChannelHandlerContext
msg - 写信息
promise - 在操作完成后通知ChannelPromise
java.lang.Exception - 发生错误时抛出
public void channelReadComplete(ChannelHandlerContext ctx) throws java.lang.Exception
ChannelInboundHandlerAdapter
ChannelHandlerContext.fireChannelReadComplete()转发到ChannelPipeline中的下一个ChannelInboundHandler 。
子类可以重写此方法来更改行为。
channelReadComplete在界面
ChannelInboundHandler
channelReadComplete ,上课
ChannelInboundHandlerAdapter
java.lang.Exception
public void channelInactive(ChannelHandlerContext ctx) throws java.lang.Exception
ChannelInboundHandlerAdapter
ChannelHandlerContext.fireChannelInactive()转发到ChannelPipeline中的下一个ChannelInboundHandler 。
子类可以重写此方法来更改行为。
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)
Copyright © 2008–2018 The Netty Project. All rights reserved.