Class MqttMsgBase
Base class for all MQTT messages
public abstract class MqttMsgBase
- Inheritance
-
MqttMsgBase
- Derived
- Inherited Members
- Extension Methods
Constructors
MqttMsgBase()
protected MqttMsgBase()
Properties
DupFlag
Duplicate message flag
public bool DupFlag { get; set; }
Property Value
MaximumPacketSize
Maximum Packet Size, v5.0 only
public uint MaximumPacketSize { get; set; }
Property Value
MessageId
Message identifier for the message
public ushort MessageId { get; set; }
Property Value
QosLevel
Quality of Service level
public MqttQoSLevel QosLevel { get; set; }
Property Value
Retain
Retain message flag
public bool Retain { get; set; }
Property Value
Type
Message type
public MqttMessageType Type { get; set; }
Property Value
UserProperties
User Property, v5.0 only
public ArrayList UserProperties { get; }
Property Value
Methods
DecodeVariableByte(IMqttNetworkChannel)
Decode remaining length reading bytes from socket
protected static int DecodeVariableByte(IMqttNetworkChannel channel)
Parameters
channelIMqttNetworkChannelChannel from reading bytes
Returns
- int
Decoded remaining length
EncodeVariableByte(int, byte[], int)
Encode remaining length and insert it into message buffer
protected int EncodeVariableByte(int remainingLength, byte[] buffer, int index)
Parameters
remainingLengthintRemaining length value to encode
bufferbyte[]Message buffer for inserting encoded value
indexintIndex from which insert encoded value into buffer
Returns
- int
Index updated
GetBytes(MqttProtocolVersion)
Returns message bytes rapresentation
public abstract byte[] GetBytes(MqttProtocolVersion protocolVersion)
Parameters
protocolVersionMqttProtocolVersionProtocol version
Returns
- byte[]
Bytes rapresentation
ReceiveExactly(IMqttNetworkChannel, byte[])
Fill the buffer with bytes read from the channel.
protected static int ReceiveExactly(IMqttNetworkChannel channel, byte[] buffer)
Parameters
channelIMqttNetworkChannelChannel from reading bytes
bufferbyte[]Buffer to fill
Returns
- int
Number of bytes received, which is always the buffer length.
Exceptions
- MqttCommunicationException
The channel is not available or the connection was closed before the buffer was filled.