Table of Contents

Interface IMqttClientWrapper

Namespace
Silverback.Messaging.Broker.Mqtt
Assembly
Silverback.Integration.MQTT.dll

Wraps the underlying MQTTnet.MqttClient and handles the connection lifecycle.

public interface IMqttClientWrapper : IBrokerClient, IDisposable, IAsyncDisposable
Inherited Members

Properties

Configuration

Gets the client configuration.

MqttClientConfiguration Configuration { get; }

Property Value

MqttClientConfiguration

Connected

Gets the AsyncEvent<TArg> that is fired when the connection with the broker is established.

AsyncEvent<BrokerClient> Connected { get; }

Property Value

AsyncEvent<BrokerClient>

IsConnected

Gets a value indicating whether the client is connected with the broker.

bool IsConnected { get; }

Property Value

bool

MessageReceived

Gets the AsyncEvent<TArg> that is fired when a message is received.

AsyncEvent<MqttApplicationMessageReceivedEventArgs> MessageReceived { get; }

Property Value

AsyncEvent<MqttApplicationMessageReceivedEventArgs>

Subscribed

Gets the AsyncEvent<TArg> that is fired when the topics are successfully subscribed.

AsyncEvent<BrokerClient> Subscribed { get; }

Property Value

AsyncEvent<BrokerClient>

SubscribedTopicsFilters

Gets the subscribed topics filters.

IReadOnlyCollection<MqttTopicFilter> SubscribedTopicsFilters { get; }

Property Value

IReadOnlyCollection<MqttTopicFilter>

Methods

Produce(byte[]?, IReadOnlyCollection<MessageHeader>?, MqttProducerEndpoint, Action<IBrokerMessageIdentifier?>, Action<Exception>)

Produces the message to the specified endpoint.

void Produce(byte[]? content, IReadOnlyCollection<MessageHeader>? headers, MqttProducerEndpoint endpoint, Action<IBrokerMessageIdentifier?> onSuccess, Action<Exception> onError)

Parameters

content byte[]

The message content.

headers IReadOnlyCollection<MessageHeader>

The message headers.

endpoint MqttProducerEndpoint

The destination endpoint (topic).

onSuccess Action<IBrokerMessageIdentifier>

A callback to be invoked when the message is successfully produced.

onError Action<Exception>

A callback to be invoked when an error occurs trying to produce the message.

SubscribeAsync()

Subscribes to all configured topics and starts consuming messages.

Task SubscribeAsync()

Returns

Task

A Task representing the asynchronous operation.

UnsubscribeAsync()

Unsubscribes from all topics and stops consuming messages.

Task UnsubscribeAsync()

Returns

Task

A Task representing the asynchronous operation.