change client config
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Torma Kristóf 2020-10-21 18:03:11 +02:00
parent 0575771daa
commit 5a0e8b842c
Signed by: tormakris
GPG Key ID: DC83C4F2C41B1047

View File

@ -6,7 +6,7 @@ class MqttSubscriber : MqttCallbackExtended {
private val broker = "tcp://mqtt.k8s.kmlabz.com:1883"
private val clientId = MqttClient.generateClientId()
private val persistence = MemoryPersistence()
private val mqttClient = MqttAsyncClient(broker, clientId, persistence)
private val mqttClient = MqttClient(broker, clientId, persistence)
private val benchValues = HashMap<Int, Instant>()
override fun connectionLost(arg0: Throwable) {
@ -25,10 +25,12 @@ class MqttSubscriber : MqttCallbackExtended {
}
override fun connectComplete(reconnect: Boolean, serverURI: String?) {
println("Subscribing to all topics")
mqttClient.subscribe("#", 0)
}
fun connect() {
println("Connecting to broker")
val connOpts = MqttConnectOptions()
connOpts.isCleanSession = true
connOpts.userName = "birbnetes"
@ -38,6 +40,7 @@ class MqttSubscriber : MqttCallbackExtended {
}
fun disconnect(): HashMap<Int, Instant> {
println("Disconnecting from broker")
mqttClient.disconnect()
mqttClient.close()
return benchValues