Mqtt Endpoint
Describes how to reach an MQTT broker.
Used as the argument to MqttClient.connect to specify the broker's address and transport. Two transport types are supported, each as a sealed subclass:
Tcp — raw TCP socket (optionally with TLS), available on JVM, Android, iOS, macOS, Linux, Windows.
WebSocket — binary WebSocket frames, available on all platforms including browser/wasmJs.
Example
// Plain TCP
val tcp = MqttEndpoint.Tcp(host = "broker.example.com", port = 1883)
// TCP with TLS
val tls = MqttEndpoint.Tcp(host = "broker.example.com", port = 8883, tls = true)
// WebSocket (browser)
val ws = MqttEndpoint.WebSocket(url = "wss://broker.example.com/mqtt")Content copied to clipboard