Click or drag to resize

MqttClientOpenAsync Method

Opens an MQTT client connection.

Namespace: Demo3D.HLE.Comms.Net
Assembly: Demo3D.HLE (in Demo3D.HLE.dll) Version: 19.00.00
Syntax
C#
public static Task<Client<IPublishSubscribeService>> OpenAsync(
	bool sync,
	string host,
	int port,
	ProtocolVersion version,
	string clientIdentifier,
	Flags flags = default
)

Parameters

sync  Boolean
If true, the Task returned is guaranteed to be complete.
host  String
The host to connect to.
port  Int32
The port number.
version  ProtocolVersion
Protocol version.
clientIdentifier  String
Client identifier.
flags  Flags  (Optional)
Connection flags.

Return Value

TaskClientIPublishSubscribeService
A new MQTT client.
Example
C#
public async Task SendMessageAsync(string host, string tsap) {
    // Open a connection to a client.
    var client = await CotpClient.OpenAsync(sync: false, host, tsap);

    // Send a message.
    var message = BinaryTextEncoding.NullTerminatedASCII.GetBytes("hello");
    await client.IO.WriteAsync(message);

    // Close the connection.
    client.Close();
}
See Also