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

Parameters

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: ClientIPublishSubscribeService
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