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: 18.03.00
Syntax
C#
public static Task<Client<IPublishSubscribeService>> OpenAsync(
	bool sync,
	string host,
	int port,
	ProtocolVersion version,
	string clientIdentifier,
	Flags flags = default
)

Parameters

sync
Type: SystemBoolean
If true, the Task returned is guaranteed to be complete.
host
Type: SystemString
The host to connect to.
port
Type: SystemInt32
The port number.
version
Type: Demo3D.HLE.Comms.MQTTProtocolVersion
Protocol version.
clientIdentifier
Type: SystemString
Client identifier.
flags (Optional)
Type: Demo3D.NetFlags
Connection flags.

Return Value

Type: TaskClientIPublishSubscribeService
A new MQTT client.
Examples
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