From 5eebdf75f7262349f4890677cd94eac3f41c2c62 Mon Sep 17 00:00:00 2001 From: Timon Date: Thu, 4 Feb 2021 13:27:10 +0100 Subject: [PATCH] Start keep alive timer before emitting connected() By chaning the order MqttClient::isConnected() returns true in slot connected to MqttClient::connected(). --- libnymea-mqtt/mqttclient.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libnymea-mqtt/mqttclient.cpp b/libnymea-mqtt/mqttclient.cpp index e164e89..d19dda4 100644 --- a/libnymea-mqtt/mqttclient.cpp +++ b/libnymea-mqtt/mqttclient.cpp @@ -364,9 +364,9 @@ void MqttClientPrivate::onReadyRead() } socket->write(retryPacket.serialize()); } + restartKeepAliveTimer(); // Make sure we emit connected after having handled all the retransmission queue emit q_ptr->connected(packet.connectReturnCode(), packet.connackFlags()); - restartKeepAliveTimer(); break; case MqttPacket::TypePublish: qCDebug(dbgClient) << "Publish received from server. Topic:" << packet.topic() << "Payload:" << packet.payload() << "QoS:" << packet.qos();