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
contentTypestring
Returns
WithCorrelationData(byte[])
Adds the correlation data to the message.
public MqttApplicationMessageBuilder WithCorrelationData(byte[] correlationData)
Parameters
correlationDatabyte[]
Returns
WithMessageExpiryInterval(uint)
Adds the message expiry interval in seconds to the message.
public MqttApplicationMessageBuilder WithMessageExpiryInterval(uint messageExpiryInterval)
Parameters
messageExpiryIntervaluint
Returns
WithPayload(ArraySegment<byte>)
public MqttApplicationMessageBuilder WithPayload(ArraySegment<byte> payloadSegment)
Parameters
payloadSegmentArraySegment<byte>
Returns
WithPayload(byte[])
public MqttApplicationMessageBuilder WithPayload(byte[] payload)
Parameters
payloadbyte[]
Returns
WithPayload(IEnumerable<byte>)
public MqttApplicationMessageBuilder WithPayload(IEnumerable<byte> payload)
Parameters
payloadIEnumerable<byte>
Returns
WithPayload(Stream)
public MqttApplicationMessageBuilder WithPayload(Stream payload)
Parameters
payloadStream
Returns
WithPayload(Stream, long)
public MqttApplicationMessageBuilder WithPayload(Stream payload, long length)
Parameters
Returns
WithPayload(string)
public MqttApplicationMessageBuilder WithPayload(string payload)
Parameters
payloadstring
Returns
WithPayloadFormatIndicator(MqttPayloadFormatIndicator)
Adds the payload format indicator to the message.
public MqttApplicationMessageBuilder WithPayloadFormatIndicator(MqttPayloadFormatIndicator payloadFormatIndicator)
Parameters
payloadFormatIndicatorMqttPayloadFormatIndicator
Returns
WithPayloadSegment(ArraySegment<byte>)
public MqttApplicationMessageBuilder WithPayloadSegment(ArraySegment<byte> payloadSegment)
Parameters
payloadSegmentArraySegment<byte>
Returns
WithPayloadSegment(ReadOnlyMemory<byte>)
public MqttApplicationMessageBuilder WithPayloadSegment(ReadOnlyMemory<byte> payloadSegment)
Parameters
payloadSegmentReadOnlyMemory<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
qualityOfServiceLevelMqttQualityOfServiceLevel
Returns
WithResponseTopic(string)
Adds the response topic to the message.
public MqttApplicationMessageBuilder WithResponseTopic(string responseTopic)
Parameters
responseTopicstring
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
valuebool
Returns
WithSubscriptionIdentifier(uint)
Adds the subscription identifier to the message.
public MqttApplicationMessageBuilder WithSubscriptionIdentifier(uint subscriptionIdentifier)
Parameters
subscriptionIdentifieruint
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
topicstring
Returns
WithTopicAlias(ushort)
Adds the topic alias to the message.
public MqttApplicationMessageBuilder WithTopicAlias(ushort topicAlias)
Parameters
topicAliasushort
Returns
WithUserProperty(string, string)
Adds the user property to the message.
public MqttApplicationMessageBuilder WithUserProperty(string name, string value)