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
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
MqttConnectionSettingsThe details about the MQTT broker to connect to.
cancellationToken
CancellationTokenCancellation 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
MqttClientOptionsThe details about the MQTT broker to connect to.
cancellationToken
CancellationTokenCancellation 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
MqttClientDisconnectOptionsThe optional parameters to include in the DISCONNECT request.
cancellationToken
CancellationTokenCancellation token.
Returns
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
CancellationTokenCancellation token.
Returns
SendEnhancedAuthenticationExchangeDataAsync(MqttEnhancedAuthenticationExchangeData, CancellationToken)
Send additional authentication data. May be done on an active connection.
Task SendEnhancedAuthenticationExchangeDataAsync(MqttEnhancedAuthenticationExchangeData data, CancellationToken cancellationToken = default)
Parameters
data
MqttEnhancedAuthenticationExchangeDataThe authentication data to send.
cancellationToken
CancellationTokenCancellation token.
Returns
Events
ConnectedAsync
An event that executes every time this client is connected.
event Func<MqttClientConnectedEventArgs, Task>? ConnectedAsync
Event Type
DisconnectedAsync
An event that executes every time this client is disconnected.
event Func<MqttClientDisconnectedEventArgs, Task>? DisconnectedAsync