Table of Contents

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

MqttApplicationMessage

WithContentType(string)

Adds the content type to the message. MQTT 5.0.0+ feature.

public MqttApplicationMessageBuilder WithContentType(string contentType)

Parameters

contentType string

Returns

MqttApplicationMessageBuilder

WithCorrelationData(byte[])

Adds the correlation data to the message. MQTT 5.0.0+ feature.

public MqttApplicationMessageBuilder WithCorrelationData(byte[] correlationData)

Parameters

correlationData byte[]

Returns

MqttApplicationMessageBuilder

WithMessageExpiryInterval(uint)

Adds the message expiry interval in seconds to the message. MQTT 5.0.0+ feature.

public MqttApplicationMessageBuilder WithMessageExpiryInterval(uint messageExpiryInterval)

Parameters

messageExpiryInterval uint

Returns

MqttApplicationMessageBuilder

WithPayload(ArraySegment<byte>)

public MqttApplicationMessageBuilder WithPayload(ArraySegment<byte> payloadSegment)

Parameters

payloadSegment ArraySegment<byte>

Returns

MqttApplicationMessageBuilder

WithPayload(byte[])

public MqttApplicationMessageBuilder WithPayload(byte[] payload)

Parameters

payload byte[]

Returns

MqttApplicationMessageBuilder

WithPayload(IEnumerable<byte>)

public MqttApplicationMessageBuilder WithPayload(IEnumerable<byte> payload)

Parameters

payload IEnumerable<byte>

Returns

MqttApplicationMessageBuilder

WithPayload(Stream)

public MqttApplicationMessageBuilder WithPayload(Stream payload)

Parameters

payload Stream

Returns

MqttApplicationMessageBuilder

WithPayload(Stream, long)

public MqttApplicationMessageBuilder WithPayload(Stream payload, long length)

Parameters

payload Stream
length long

Returns

MqttApplicationMessageBuilder

WithPayload(string)

public MqttApplicationMessageBuilder WithPayload(string payload)

Parameters

payload string

Returns

MqttApplicationMessageBuilder

WithPayloadFormatIndicator(MqttPayloadFormatIndicator)

Adds the payload format indicator to the message. MQTT 5.0.0+ feature.

public MqttApplicationMessageBuilder WithPayloadFormatIndicator(MqttPayloadFormatIndicator payloadFormatIndicator)

Parameters

payloadFormatIndicator MqttPayloadFormatIndicator

Returns

MqttApplicationMessageBuilder

WithPayloadSegment(ArraySegment<byte>)

public MqttApplicationMessageBuilder WithPayloadSegment(ArraySegment<byte> payloadSegment)

Parameters

payloadSegment ArraySegment<byte>

Returns

MqttApplicationMessageBuilder

WithPayloadSegment(ReadOnlyMemory<byte>)

public MqttApplicationMessageBuilder WithPayloadSegment(ReadOnlyMemory<byte> payloadSegment)

Parameters

payloadSegment ReadOnlyMemory<byte>

Returns

MqttApplicationMessageBuilder

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

MqttApplicationMessageBuilder

WithResponseTopic(string)

Adds the response topic to the message. MQTT 5.0.0+ feature.

public MqttApplicationMessageBuilder WithResponseTopic(string responseTopic)

Parameters

responseTopic string

Returns

MqttApplicationMessageBuilder

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

MqttApplicationMessageBuilder

WithSubscriptionIdentifier(uint)

Adds the subscription identifier to the message. MQTT 5.0.0+ feature.

public MqttApplicationMessageBuilder WithSubscriptionIdentifier(uint subscriptionIdentifier)

Parameters

subscriptionIdentifier uint

Returns

MqttApplicationMessageBuilder

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

MqttApplicationMessageBuilder

WithTopicAlias(ushort)

Adds the topic alias to the message. MQTT 5.0.0+ feature.

public MqttApplicationMessageBuilder WithTopicAlias(ushort topicAlias)

Parameters

topicAlias ushort

Returns

MqttApplicationMessageBuilder

WithUserProperty(string, string)

Adds the user property to the message. MQTT 5.0.0+ feature.

public MqttApplicationMessageBuilder WithUserProperty(string name, string value)

Parameters

name string
value string

Returns

MqttApplicationMessageBuilder