Connection¶
Namespace: MQTT_Receiver_Worker.MQTT
Handles MQTT broker connection and message processing.
Establishes a connection to the MQTT broker, subscribes to topics,
and processes incoming temperature sensor messages.
Inheritance Object → Connection
Implements IConnection
Properties¶
IsConnected¶
Gets a value indicating whether the MQTT client is currently connected.
Property Value¶
Constructors¶
Connection(ILogger<Connection>, IServiceProvider, IConfiguration)¶
Initializes a new instance of the Connection class.
public Connection(ILogger<Connection> logger, IServiceProvider serviceProvider, IConfiguration configuration)
Parameters¶
logger
ILogger<Connection>
Logger for recording connection events
serviceProvider
IServiceProvider
configuration
IConfiguration
Configuration for MQTT settings
Methods¶
DisconnectAsync()¶
Disconnects from the MQTT broker.
Returns¶
A task that represents the asynchronous operation.
GetConnectionAsync()¶
Establishes a connection to the MQTT broker and configures message handlers.
Returns¶
A task that represents the asynchronous operation. The task result contains the connected MQTT client, or null if connection failed.
TryConnectAsync()¶
Attempts to connect to the MQTT broker.
Returns¶
A task that represents the asynchronous operation. The task result indicates whether the connection was successful.