Table of Contents

Interface IMqttClient

Namespace
Azure.Iot.Operations.Protocol
Assembly
Azure.Iot.Operations.Protocol.dll

An MQTT client interface that allows for connection management as well as publishing, subscribing, and unsubscribing.

public interface IMqttClient : IMqttPubSubClient, IAsyncDisposable
Inherited Members

Properties

IsConnected

Get if this MQTT client is currently connected or not.

bool IsConnected { get; }

Property Value

bool

Methods

ConnectAsync(MqttConnectionSettings, CancellationToken)

Connect this client to the MQTT broker configured in the provided connection settings.

Task<MqttClientConnectResult> ConnectAsync(MqttConnectionSettings settings, CancellationToken cancellationToken = default)

Parameters

settings MqttConnectionSettings

The details about the MQTT broker to connect to.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<MqttClientConnectResult>

The CONNACK returned by the MQTT broker.

ConnectAsync(MqttClientOptions, CancellationToken)

Connect this client to the MQTT broker configured in the provided connection options.

Task<MqttClientConnectResult> ConnectAsync(MqttClientOptions options, CancellationToken cancellationToken = default)

Parameters

options MqttClientOptions

The details about the MQTT broker to connect to.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<MqttClientConnectResult>

The CONNACK returned by the MQTT broker.

DisconnectAsync(MqttClientDisconnectOptions?, CancellationToken)

Disconnect this client from the MQTT broker.

Task DisconnectAsync(MqttClientDisconnectOptions? options = null, CancellationToken cancellationToken = default)

Parameters

options MqttClientDisconnectOptions

The optional parameters to include in the DISCONNECT request.

cancellationToken CancellationToken

Cancellation token.

Returns

Task

ReconnectAsync(CancellationToken)

Reconnect the client if it is disconnected. This will use the MqttClientOptions last provided when connecting.

Task ReconnectAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Cancellation token.

Returns

Task

SendEnhancedAuthenticationExchangeDataAsync(MqttEnhancedAuthenticationExchangeData, CancellationToken)

Send additional authentication data. May be done on an active connection.

Task SendEnhancedAuthenticationExchangeDataAsync(MqttEnhancedAuthenticationExchangeData data, CancellationToken cancellationToken = default)

Parameters

data MqttEnhancedAuthenticationExchangeData

The authentication data to send.

cancellationToken CancellationToken

Cancellation token.

Returns

Task

Events

ConnectedAsync

An event that executes every time this client is connected.

event Func<MqttClientConnectedEventArgs, Task>? ConnectedAsync

Event Type

Func<MqttClientConnectedEventArgs, Task>

DisconnectedAsync

An event that executes every time this client is disconnected.

event Func<MqttClientDisconnectedEventArgs, Task>? DisconnectedAsync

Event Type

Func<MqttClientDisconnectedEventArgs, Task>