Click or drag to resize

MqttClientOpen 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 Client<IPublishSubscribeService> Open(
	string host,
	int port,
	ProtocolVersion version,
	string clientIdentifier,
	Flags flags = default
)

Parameters

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

ClientIPublishSubscribeService
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