Mqtt Client
fun MqttClient(clientId: String, scope: CoroutineScope = CoroutineScope(SupervisorJob() + Dispatchers.Default), configure: MqttConfig.Builder.() -> Unit = {}): MqttClient
Creates an MqttClient with the given clientId and optional configuration.
Shorthand factory that combines client ID with the MqttConfig.Builder DSL:
val client = MqttClient("sensor-hub") {
keepAliveSeconds = 30
autoReconnect = true
logger = MqttLogger.println()
logLevel = MqttLogLevel.DEBUG
}Content copied to clipboard
Parameters
client Id
Client identifier sent to the broker.
scope
Coroutine scope for background jobs.
configure
Optional configuration block.