Interface IMqttClientWrapper
Wraps the underlying MQTTnet.MqttClient and handles the connection lifecycle.
Inherited Members
Namespace: Silverback.Messaging.Broker.Mqtt
Assembly: Silverback.Integration.MQTT.dll
Syntax
public interface IMqttClientWrapper : IBrokerClient, IDisposable, IAsyncDisposable
Properties
Configuration
Gets the client configuration.
Declaration
MqttClientConfiguration Configuration { get; }
Property Value
| Type | Description |
|---|---|
| MqttClientConfiguration |
Connected
Gets the AsyncEvent<TArg> that is fired when the connection with the broker is established.
Declaration
AsyncEvent<BrokerClient> Connected { get; }
Property Value
| Type | Description |
|---|---|
| AsyncEvent<BrokerClient> |
IsConnected
Gets a value indicating whether the client is connected with the broker.
Declaration
bool IsConnected { get; }
Property Value
| Type | Description |
|---|---|
| bool |
MessageReceived
Gets the AsyncEvent<TArg> that is fired when a message is received.
Declaration
AsyncEvent<MqttApplicationMessageReceivedEventArgs> MessageReceived { get; }
Property Value
| Type | Description |
|---|---|
| AsyncEvent<MqttApplicationMessageReceivedEventArgs> |
Subscribed
Gets the AsyncEvent<TArg> that is fired when the topics are successfully subscribed.
Declaration
AsyncEvent<BrokerClient> Subscribed { get; }
Property Value
| Type | Description |
|---|---|
| AsyncEvent<BrokerClient> |
SubscribedTopicsFilters
Gets the subscribed topics filters.
Declaration
IReadOnlyCollection<MqttTopicFilter> SubscribedTopicsFilters { get; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyCollection<MqttTopicFilter> |
Methods
Produce(byte[]?, IReadOnlyCollection<MessageHeader>?, MqttProducerEndpoint, Action<IBrokerMessageIdentifier?>, Action<Exception>)
Produces the message to the specified endpoint.
Declaration
void Produce(byte[]? content, IReadOnlyCollection<MessageHeader>? headers, MqttProducerEndpoint endpoint, Action<IBrokerMessageIdentifier?> onSuccess, Action<Exception> onError)
Parameters
| Type | Name | Description |
|---|---|---|
| byte[] | content | The message content. |
| IReadOnlyCollection<MessageHeader> | headers | The message headers. |
| MqttProducerEndpoint | endpoint | The destination endpoint (topic). |
| Action<IBrokerMessageIdentifier> | onSuccess | A callback to be invoked when the message is successfully produced. |
| Action<Exception> | onError | A callback to be invoked when an error occurs trying to produce the message. |
SubscribeAsync()
Subscribes to all configured topics and starts consuming messages.
Declaration
Task SubscribeAsync()
Returns
| Type | Description |
|---|---|
| Task | A Task representing the asynchronous operation. |
UnsubscribeAsync()
Unsubscribes from all topics and stops consuming messages.
Declaration
Task UnsubscribeAsync()
Returns
| Type | Description |
|---|---|
| Task | A Task representing the asynchronous operation. |