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 ByteBufdoEncode(ChannelHandlerContext ctx, MqttMessage message) This is the main encoding method.protected voidencode(ChannelHandlerContext ctx, MqttMessage msg, List<Object> out) Encode from one message to an other.private static ByteBufencodeConnAckMessage(ChannelHandlerContext ctx, MqttConnAckMessage message) private static ByteBufencodeConnectMessage(ChannelHandlerContext ctx, MqttConnectMessage message) private static ByteBufencodeMessageWithOnlySingleByteFixedHeader(ByteBufAllocator byteBufAllocator, MqttMessage message) private static ByteBufencodeMessageWithOnlySingleByteFixedHeaderAndMessageId(ByteBufAllocator byteBufAllocator, MqttMessage message) private static ByteBufencodeProperties(ByteBufAllocator byteBufAllocator, MqttProperties mqttProperties) private static ByteBufencodePropertiesIfNeeded(MqttVersion mqttVersion, ByteBufAllocator byteBufAllocator, MqttProperties mqttProperties) private static ByteBufencodePublishMessage(ChannelHandlerContext ctx, MqttPublishMessage message) private static ByteBufencodePubReplyMessage(ChannelHandlerContext ctx, MqttMessage message) private static ByteBufprivate static ByteBufencodeSubAckMessage(ChannelHandlerContext ctx, MqttSubAckMessage message) private static ByteBufencodeSubscribeMessage(ChannelHandlerContext ctx, MqttSubscribeMessage message) private static ByteBufencodeUnsubAckMessage(ChannelHandlerContext ctx, MqttUnsubAckMessage message) private static ByteBufprivate static intgetConnVariableHeaderFlag(MqttConnectVariableHeader variableHeader) private static intgetFixedHeaderByte1(MqttFixedHeader header) private static intgetVariableLengthInt(int num) private static intprivate static intprivate static voidwriteEagerUTF8String(ByteBuf buf, String s) private static voidwriteExactUTF8String(ByteBuf buf, String s, int utf8Length) private static voidwriteVariableLengthInt(ByteBuf buf, int num) Methods inherited from class io.netty.handler.codec.MessageToMessageEncoder
acceptOutboundMessage, writeMethods inherited from class io.netty.channel.ChannelOutboundHandlerAdapter
bind, close, connect, deregister, disconnect, flush, readMethods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, exceptionCaught, handlerAdded, handlerRemoved, isSharableMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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:MessageToMessageEncoderEncode from one message to an other. This method will be called for each written message that can be handled by this encoder.- Specified by:
encodein classMessageToMessageEncoder<MqttMessage>- Parameters:
ctx- theChannelHandlerContextwhich thisMessageToMessageEncoderbelongs tomsg- the message to encode to an other oneout- theListinto 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
-
getVariableLengthInt
private static int getVariableLengthInt(int num)
-