WebSocketTransport

class WebSocketTransport(configureTls: TLSConfigBuilder.() -> Unit? = null) : MqttTransport

WebSocket-based MqttTransport for all platforms, including the browser (wasmJs).

Uses Ktor's multiplatform HttpClient with a per-platform engine (CIO on JVM/Android/Apple/Linux, WinHttp on Windows, Js on wasmJs/browser). One binary WebSocket frame = one complete MQTT packet, so no stream parsing is needed — the WebSocket layer handles framing.

Parameters

configureTls

optional hook applied to the engine's TLS configuration before platform trust is configured. Use it to trust a private or self-signed CA for this connection only. Honoured on JVM, Android, Apple, and Linux; ignored on Windows and in the browser.

Constructors

Link copied to clipboard
constructor(configureTls: TLSConfigBuilder.() -> Unit? = null)
constructor()

Properties

Link copied to clipboard
open override val isConnected: Boolean

Functions

Link copied to clipboard
open suspend override fun close()
Link copied to clipboard
open suspend override fun connect(endpoint: MqttEndpoint)
Link copied to clipboard
open suspend override fun receive(): ByteArray
Link copied to clipboard
open suspend override fun send(bytes: ByteArray)