import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.delay import kotlinx.coroutines.launch import kotlinx.coroutines.runBlocking fun main() = runBlocking{ GlobalScope.launch { val mqtt = MqttSubscriber() mqtt.connect() delay(10000L) mqtt.disconnect() } delay(20000L) }