GeezerVison is showing netty.io — ByteToMessageDecoder (Netty API Reference (4.1.141.Final))
Class ByteToMessageDecoder
- All Implemented Interfaces:
ChannelHandler, ChannelInboundHandler
- Direct Known Subclasses:
AbstractMemcacheObjectDecoder, BrotliDecoder, Bzip2Decoder, CleartextHttp2ServerUpgradeHandler, DelimiterBasedFrameDecoder, FastLzFrameDecoder, FixedLengthFrameDecoder, HAProxyMessageDecoder, Http2ConnectionHandler, HttpObjectDecoder, JsonObjectDecoder, LengthFieldBasedFrameDecoder, LineBasedFrameDecoder, Lz4FrameDecoder, LzfDecoder, OcspServerCertificateValidator, OptionalSslHandler, ProtobufVarint32FrameDecoder, RedisDecoder, ReplayingDecoder, SnappyFrameDecoder, SocksPortUnificationServerHandler, SpdyFrameCodec, SslClientHelloHandler, SslHandler, WebSocket08FrameDecoder, XmlDecoder, XmlFrameDecoder, ZlibDecoder, ZstdDecoder
-
Nested Class Summary
Nested Classes
Modifier and Type
Class
Description
static interface
-
Field Summary
Fields
Modifier and Type
Field
Description
Cumulate ByteBufs by merge them into one ByteBuf's, using memory copies.
-
Constructor Summary
Constructors
Modifier
Constructor
Description
protected
-
Method Summary
Modifier and Type
Method
Description
protected int
Returns the actual number of readable bytes in the internal cumulative
buffer of this decoder.
protected void
Called once data should be decoded from the given ByteBuf.
void
void
void
protected abstract void
Decode the from one ByteBuf to an other.
protected void
protected final void
final void
Do nothing by default, sub-classes may override this method.
protected void
Gets called after the ByteToMessageDecoder was removed from the actual context and it doesn't handle
events anymore.
Returns the internal cumulative buffer of this decoder.
boolean
void
void
void
void
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
MERGE_CUMULATOR
Cumulate ByteBufs by merge them into one ByteBuf's, using memory copies.
-
COMPOSITE_CUMULATOR
Cumulate ByteBufs by add them to a CompositeByteBuf and so do no memory copy whenever possible.
Be aware that CompositeByteBuf use a more complex indexing implementation so depending on your use-case
and the decoder implementation this may be slower than just use the MERGE_CUMULATOR.
-
Constructor Details
-
ByteToMessageDecoder
protected ByteToMessageDecoder()
-
Method Details
-
setSingleDecode
public void setSingleDecode(boolean singleDecode)
If set then only one message is decoded on each channelRead(ChannelHandlerContext, Object)
call. This may be useful if you need to do some protocol upgrade and want to make sure nothing is mixed up.
Default is false as this has performance impacts.
-
isSingleDecode
public boolean isSingleDecode()
-
-
setDiscardAfterReads
public void setDiscardAfterReads(int discardAfterReads)
-
actualReadableBytes
protected int actualReadableBytes()
Returns the actual number of readable bytes in the internal cumulative
buffer of this decoder. You usually do not need to rely on this value
to write a decoder. Use it only when you must use it at your own risk.
This method is a shortcut to internalBuffer().readableBytes().
-
internalBuffer
Returns the internal cumulative buffer of this decoder. You usually
do not need to access the internal buffer directly to write a decoder.
Use it only when you must use it at your own risk.
-
-
-
-
-
discardSomeReadBytes
protected final void discardSomeReadBytes()
-
-
-
-
decode
Decode the from one ByteBuf to an other. This method will be called till either the input
ByteBuf has nothing to read when return from this method or till nothing was read from the input
ByteBuf.
- Parameters:
ctx - the ChannelHandlerContext which this ByteToMessageDecoder belongs to
in - the ByteBuf from which to read data
out - the List to which decoded messages should be added
- Throws:
Exception - is thrown if an error occurs
-
|