Class MqttServer
- Namespace
- NominalSystems.External
- Assembly
- NominalSystems.External.dll
This class is a wrapper for an Mqtt Server, also known as a Broker
public class MqttServer
- Inheritance
-
MqttServer
Constructors
MqttServer()
Default constructor for the server
public MqttServer()
Fields
ClientIDs
List of connected client IDs
public List<string> ClientIDs
Field Value
NumClients
Number of connected Clients
public int NumClients
Field Value
Properties
IsStarted
Tracks whether the server has started or not
public bool IsStarted { get; }
Property Value
Methods
CheckClientConnected(string)
Checks if a specific client is connected to the Server
public bool CheckClientConnected(string clientID)
Parameters
clientID
stringThe Client ID to return the tracked connected status of
Returns
- bool
Returns true if the specific client is connected
DisconnectAllClients()
Disconnects all connected Clients that are connected to the Server
public Task DisconnectAllClients()
Returns
DisconnectClient(string)
Disconnects a Specific Client that is connected to the Server
public Task DisconnectClient(string clientID)
Parameters
clientID
stringThe Client ID of the connected Client to disconnect
Returns
ShutdownServer(double)
Attempts to shutdown the Server, within the provided timeout duration. This will pause the current thread until the shutdown is complete
public bool ShutdownServer(double timeout = 0)
Parameters
timeout
double[s] The timeout to wait for. If the timeout is exceeded, the loop will break
Returns
- bool
Returns true if the Server was shutdown
WaitForNumberOfConnectedClients(int, double)
Waits for the target number of clients to be connected to the server. This will pause the current thread until the target is reached or the timeout is triggered
public bool WaitForNumberOfConnectedClients(int targetNumber, double timeout = 0)
Parameters
targetNumber
int[-] The target number of clients to be connected to the server
timeout
double[s] The timeout to wait for. If the timeout is exceeded, the loop will break
Returns
- bool
Returns if the target number of connected clients was reached