public class LineBasedFrameDecoder extends ByteToMessageDecoder
ByteBuf分解为行尾。
处理"\n"和"\r\n" 。 对于更通用的基于分隔符的解码器,请参阅DelimiterBasedFrameDecoder 。
ByteToMessageDecoder.CumulatorChannelHandler.SharableCOMPOSITE_CUMULATOR, MERGE_CUMULATOR| Constructor and Description |
|---|
LineBasedFrameDecoder(int maxLength)
创建一个新的解码器。
|
LineBasedFrameDecoder(int maxLength, boolean stripDelimiter, boolean failFast)
创建一个新的解码器。
|
| Modifier and Type | Method and Description |
|---|---|
protected java.lang.Object |
decode(ChannelHandlerContext ctx, ByteBuf buffer)
从 ByteBuf中创建一个框架并将其返回。
|
protected void |
decode(ChannelHandlerContext ctx, ByteBuf in, java.util.List<java.lang.Object> out)
解码从一个 ByteBuf到另一个。
|
actualReadableBytes, callDecode, channelInactive, channelRead, channelReadComplete, decodeLast, discardSomeReadBytes, handlerRemoved, handlerRemoved0, internalBuffer, isSingleDecode, setCumulator, setDiscardAfterReads, setSingleDecode, userEventTriggeredchannelActive, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaughtensureNotSharable, handlerAdded, isSharableclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waithandlerAddedpublic LineBasedFrameDecoder(int maxLength)
maxLength - 解码帧的最大长度。
如果帧的长度超过此值,则会引发TooLongFrameException 。
public LineBasedFrameDecoder(int maxLength,
boolean stripDelimiter,
boolean failFast)
maxLength - 解码帧的最大长度。
如果帧的长度超过此值,则会引发TooLongFrameException 。
stripDelimiter - 解码后的帧是否应该删除分隔符
failFast - 如果true ,解码器注意到TooLongFrameException会被抛出,帧的长度将超过maxFrameLength ,无论整个帧是否已被读取。
如果false,一个TooLongFrameException超过maxFrameLength整个框架已经被读取之后被抛出。
protected final void decode(ChannelHandlerContext ctx, ByteBuf in, java.util.List<java.lang.Object> out) throws java.lang.Exception
ByteToMessageDecoder
decode在课程
ByteToMessageDecoder
ctx - ByteToMessageDecoder属于的ChannelHandlerContext
in - 从中读取数据的ByteBuf
out - 应该添加解码消息的
List
java.lang.Exception - 发生错误时抛出
protected java.lang.Object decode(ChannelHandlerContext ctx, ByteBuf buffer) throws java.lang.Exception
ByteBuf中创建一个框架并将其返回。
ctx - ByteToMessageDecoder属于的ChannelHandlerContext
buffer - 从中读取数据的ByteBuf
ByteBuf代表帧或null 。
java.lang.Exception
Copyright © 2008–2018 The Netty Project. All rights reserved.