GeezerVison is showing netty.io — MessageToByteEncoder (Netty API Reference (4.1.141.Final))
Class MessageToByteEncoder<I>
- All Implemented Interfaces:
ChannelHandler, ChannelOutboundHandler
- Direct Known Subclasses:
BrotliEncoder, Bzip2Encoder, CompatibleMarshallingEncoder, CompatibleObjectEncoder, FastLzFrameEncoder, HAProxyMessageEncoder, Lz4FrameEncoder, LzfEncoder, LzmaFrameEncoder, MarshallingEncoder, ObjectEncoder, ProtobufVarint32LengthFieldPrepender, SnappyFrameEncoder, Socks4ClientEncoder, Socks4ServerEncoder, Socks5ClientEncoder, Socks5ServerEncoder, SocksMessageEncoder, TcpDnsQueryEncoder, ZlibEncoder, ZstdEncoder
-
-
Constructor Summary
Constructors
Modifier
Constructor
Description
protected
protected
Create a new instance which will try to detect the types to match out of the type parameter of the class.
protected
protected
-
Method Summary
Modifier and Type
Method
Description
boolean
Returns true if the given message should be handled.
protected abstract void
protected boolean
void
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
MessageToByteEncoder
protected MessageToByteEncoder()
-
MessageToByteEncoder
protected MessageToByteEncoder(Class<? extends I> outboundMessageType)
-
MessageToByteEncoder
protected MessageToByteEncoder(boolean preferDirect)
Create a new instance which will try to detect the types to match out of the type parameter of the class.
- Parameters:
preferDirect - true if a direct ByteBuf should be tried to be used as target for
the encoded messages. If false is used it will allocate a heap
ByteBuf, which is backed by an byte array.
-
MessageToByteEncoder
protected MessageToByteEncoder(Class<? extends I> outboundMessageType,
boolean preferDirect)
Create a new instance
- Parameters:
outboundMessageType - The type of messages to match
preferDirect - true if a direct ByteBuf should be tried to be used as target for
the encoded messages. If false is used it will allocate a heap
ByteBuf, which is backed by an byte array.
-
Method Details
-
-
-
-
encode
Encode a message into a ByteBuf. This method will be called for each written message that can be handled
by this encoder.
- Parameters:
ctx - the ChannelHandlerContext which this MessageToByteEncoder belongs to
msg - the message to encode
out - the ByteBuf into which the encoded message will be written
- Throws:
Exception - is thrown if an error occurs
-
isPreferDirect
protected boolean isPreferDirect()
|