Package io.netty.handler.codec.mqtt
Class MqttEncoder
java.lang.Object
- All Implemented Interfaces:
ChannelHandler
,ChannelOutboundHandler
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
ChannelHandler.Sharable
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) static ByteBuf
doEncode
(ChannelHandlerContext ctx, MqttMessage message) This is the main encoding method.protected void
encode
(ChannelHandlerContext ctx, MqttMessage msg, List<Object> out) Encode from one message to an other.private static ByteBuf
encodeConnAckMessage
(ChannelHandlerContext ctx, MqttConnAckMessage message) private static ByteBuf
encodeConnectMessage
(ChannelHandlerContext ctx, MqttConnectMessage message) private static ByteBuf
encodeMessageWithOnlySingleByteFixedHeader
(ByteBufAllocator byteBufAllocator, MqttMessage message) private static ByteBuf
encodeMessageWithOnlySingleByteFixedHeaderAndMessageId
(ByteBufAllocator byteBufAllocator, MqttMessage message) private static ByteBuf
encodeProperties
(ByteBufAllocator byteBufAllocator, MqttProperties mqttProperties) private static ByteBuf
encodePropertiesIfNeeded
(MqttVersion mqttVersion, ByteBufAllocator byteBufAllocator, MqttProperties mqttProperties) private static ByteBuf
encodePublishMessage
(ChannelHandlerContext ctx, MqttPublishMessage message) private static ByteBuf
encodePubReplyMessage
(ChannelHandlerContext ctx, MqttMessage message) private static ByteBuf
private static ByteBuf
encodeSubAckMessage
(ChannelHandlerContext ctx, MqttSubAckMessage message) private static ByteBuf
encodeSubscribeMessage
(ChannelHandlerContext ctx, MqttSubscribeMessage message) private static ByteBuf
encodeUnsubAckMessage
(ChannelHandlerContext ctx, MqttUnsubAckMessage message) private static ByteBuf
private static int
getConnVariableHeaderFlag
(MqttConnectVariableHeader variableHeader) private static int
getFixedHeaderByte1
(MqttFixedHeader header) private static int
getVariableLengthInt
(int num) private static int
private static int
private static void
writeEagerUTF8String
(ByteBuf buf, String s) private static void
writeExactUTF8String
(ByteBuf buf, String s, int utf8Length) private static void
writeUnsafeUTF8String
(ByteBuf buf, String s) private static void
writeVariableLengthInt
(ByteBuf buf, int num) Methods inherited from class io.netty.handler.codec.MessageToMessageEncoder
acceptOutboundMessage, write
Methods inherited from class io.netty.channel.ChannelOutboundHandlerAdapter
bind, close, connect, deregister, disconnect, flush, read
Methods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, exceptionCaught, handlerAdded, handlerRemoved, isSharable
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.netty.channel.ChannelHandler
exceptionCaught, handlerAdded, handlerRemoved
-
Field Details
-
INSTANCE
-
-
Constructor Details
-
MqttEncoder
private MqttEncoder()
-
-
Method Details
-
encode
protected void encode(ChannelHandlerContext ctx, MqttMessage msg, List<Object> out) throws Exception Description copied from class:MessageToMessageEncoder
Encode from one message to an other. This method will be called for each written message that can be handled by this encoder.- Specified by:
encode
in classMessageToMessageEncoder<MqttMessage>
- Parameters:
ctx
- theChannelHandlerContext
which thisMessageToMessageEncoder
belongs tomsg
- the message to encode to an other oneout
- theList
into which the encoded msg should be added needs to do some kind of aggregation- Throws:
Exception
- is thrown if an error occurs
-
doEncode
This is the main encoding method. It's only visible for testing.- Parameters:
message
- MQTT message to encode- Returns:
- ByteBuf with encoded bytes
-
encodeConnectMessage
-
getConnVariableHeaderFlag
-
encodeConnAckMessage
-
encodeSubscribeMessage
private static ByteBuf encodeSubscribeMessage(ChannelHandlerContext ctx, MqttSubscribeMessage message) -
encodeUnsubscribeMessage
private static ByteBuf encodeUnsubscribeMessage(ChannelHandlerContext ctx, MqttUnsubscribeMessage message) -
encodeSubAckMessage
-
encodeUnsubAckMessage
private static ByteBuf encodeUnsubAckMessage(ChannelHandlerContext ctx, MqttUnsubAckMessage message) -
encodePublishMessage
-
encodePubReplyMessage
-
encodeMessageWithOnlySingleByteFixedHeaderAndMessageId
private static ByteBuf encodeMessageWithOnlySingleByteFixedHeaderAndMessageId(ByteBufAllocator byteBufAllocator, MqttMessage message) -
encodeReasonCodePlusPropertiesMessage
private static ByteBuf encodeReasonCodePlusPropertiesMessage(ChannelHandlerContext ctx, MqttMessage message) -
encodeMessageWithOnlySingleByteFixedHeader
private static ByteBuf encodeMessageWithOnlySingleByteFixedHeader(ByteBufAllocator byteBufAllocator, MqttMessage message) -
encodePropertiesIfNeeded
private static ByteBuf encodePropertiesIfNeeded(MqttVersion mqttVersion, ByteBufAllocator byteBufAllocator, MqttProperties mqttProperties) -
encodeProperties
private static ByteBuf encodeProperties(ByteBufAllocator byteBufAllocator, MqttProperties mqttProperties) -
getFixedHeaderByte1
-
writeVariableLengthInt
-
nullableUtf8Bytes
-
nullableMaxUtf8Bytes
-
writeExactUTF8String
-
writeEagerUTF8String
-
writeUnsafeUTF8String
-
getVariableLengthInt
private static int getVariableLengthInt(int num)
-