use coroutines
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-10-21 18:13:27 +02:00
parent 5a0e8b842c
commit 9da308c063
3 changed files with 13 additions and 6 deletions

View File

@ -6,11 +6,12 @@ class MqttSubscriber : MqttCallbackExtended {
private val broker = "tcp://mqtt.k8s.kmlabz.com:1883"
private val clientId = MqttClient.generateClientId()
private val persistence = MemoryPersistence()
private val mqttClient = MqttClient(broker, clientId, persistence)
private val mqttClient = MqttAsyncClient(broker, clientId, persistence)
private val benchValues = HashMap<Int, Instant>()
override fun connectionLost(arg0: Throwable) {
System.err.println("connection lost")
mqttClient.reconnect()
}
override fun deliveryComplete(arg0: IMqttDeliveryToken) {
@ -21,7 +22,6 @@ class MqttSubscriber : MqttCallbackExtended {
println("topic: $topic")
benchValues.put(topic.split("/")[1].toInt(),Instant.now())
println("message: " + String(message.payload))
}
override fun connectComplete(reconnect: Boolean, serverURI: String?) {