will

fun will(block: WillConfig.Builder.() -> Unit)

Configure a will message using a DSL block.

The broker publishes this message when the client disconnects unexpectedly. This is the Ktor-style alternative to assigning will directly.

MqttClient("sensor") {
will {
topic = "sensors/status"
payload("offline")
qos = QoS.AT_LEAST_ONCE
retain = true
}
}

Parameters

block

Configuration block applied to a WillConfig.Builder.


Optional will message published on unexpected disconnect (§3.1.3.2).