Class MqttApplicationMessageBuilder
- Namespace
- MQTTnet
- Assembly
- MQTTnet.dll
public sealed class MqttApplicationMessageBuilder
- Inheritance
-
MqttApplicationMessageBuilder
- Inherited Members
Constructors
MqttApplicationMessageBuilder()
public MqttApplicationMessageBuilder()
Methods
Build()
public MqttApplicationMessage Build()
Returns
WithContentType(string)
Adds the content type to the message.
public MqttApplicationMessageBuilder WithContentType(string contentType)
Parameters
contentType
string
Returns
WithCorrelationData(byte[])
Adds the correlation data to the message.
public MqttApplicationMessageBuilder WithCorrelationData(byte[] correlationData)
Parameters
correlationData
byte[]
Returns
WithMessageExpiryInterval(uint)
Adds the message expiry interval in seconds to the message.
public MqttApplicationMessageBuilder WithMessageExpiryInterval(uint messageExpiryInterval)
Parameters
messageExpiryInterval
uint
Returns
WithPayload(ArraySegment<byte>)
public MqttApplicationMessageBuilder WithPayload(ArraySegment<byte> payloadSegment)
Parameters
payloadSegment
ArraySegment<byte>
Returns
WithPayload(byte[])
public MqttApplicationMessageBuilder WithPayload(byte[] payload)
Parameters
payload
byte[]
Returns
WithPayload(IEnumerable<byte>)
public MqttApplicationMessageBuilder WithPayload(IEnumerable<byte> payload)
Parameters
payload
IEnumerable<byte>
Returns
WithPayload(Stream)
public MqttApplicationMessageBuilder WithPayload(Stream payload)
Parameters
payload
Stream
Returns
WithPayload(Stream, long)
public MqttApplicationMessageBuilder WithPayload(Stream payload, long length)
Parameters
Returns
WithPayload(string)
public MqttApplicationMessageBuilder WithPayload(string payload)
Parameters
payload
string
Returns
WithPayloadFormatIndicator(MqttPayloadFormatIndicator)
Adds the payload format indicator to the message.
public MqttApplicationMessageBuilder WithPayloadFormatIndicator(MqttPayloadFormatIndicator payloadFormatIndicator)
Parameters
payloadFormatIndicator
MqttPayloadFormatIndicator
Returns
WithPayloadSegment(ArraySegment<byte>)
public MqttApplicationMessageBuilder WithPayloadSegment(ArraySegment<byte> payloadSegment)
Parameters
payloadSegment
ArraySegment<byte>
Returns
WithPayloadSegment(ReadOnlyMemory<byte>)
public MqttApplicationMessageBuilder WithPayloadSegment(ReadOnlyMemory<byte> payloadSegment)
Parameters
payloadSegment
ReadOnlyMemory<byte>
Returns
WithQualityOfServiceLevel(MqttQualityOfServiceLevel)
The quality of service level. The Quality of Service (QoS) level is an agreement between the sender of a message and the receiver of a message that defines the guarantee of delivery for a specific message. There are 3 QoS levels in MQTT:
- At most once (0): Message gets delivered no time, once or multiple times.
- At least once (1): Message gets delivered at least once (one time or more often).
- Exactly once (2): Message gets delivered exactly once (It's ensured that the message only comes once).
public MqttApplicationMessageBuilder WithQualityOfServiceLevel(MqttQualityOfServiceLevel qualityOfServiceLevel)
Parameters
qualityOfServiceLevel
MqttQualityOfServiceLevel
Returns
WithResponseTopic(string)
Adds the response topic to the message.
public MqttApplicationMessageBuilder WithResponseTopic(string responseTopic)
Parameters
responseTopic
string
Returns
WithRetainFlag(bool)
A value indicating whether the message should be retained or not. A retained message is a normal MQTT message with the retained flag set to true. The broker stores the last retained message and the corresponding QoS for that topic.
public MqttApplicationMessageBuilder WithRetainFlag(bool value = true)
Parameters
value
bool
Returns
WithSubscriptionIdentifier(uint)
Adds the subscription identifier to the message.
public MqttApplicationMessageBuilder WithSubscriptionIdentifier(uint subscriptionIdentifier)
Parameters
subscriptionIdentifier
uint
Returns
WithTopic(string)
The MQTT topic. In MQTT, the word topic refers to an UTF-8 string that the broker uses to filter messages for each connected client. The topic consists of one or more topic levels. Each topic level is separated by a forward slash (topic level separator).
public MqttApplicationMessageBuilder WithTopic(string topic)
Parameters
topic
string
Returns
WithTopicAlias(ushort)
Adds the topic alias to the message.
public MqttApplicationMessageBuilder WithTopicAlias(ushort topicAlias)
Parameters
topicAlias
ushort
Returns
WithUserProperty(string, string)
Adds the user property to the message.
public MqttApplicationMessageBuilder WithUserProperty(string name, string value)