From 1b9eed1755bc361706f0591d55d2bd334c5d25e4 Mon Sep 17 00:00:00 2001 From: Wiebe Cazemier Date: Tue, 25 May 2021 15:46:41 +0200 Subject: [PATCH] Support disabling keep-alives --- client.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+), 0 deletions(-) diff --git a/client.cpp b/client.cpp index b33d3b5..709a53a 100644 --- a/client.cpp +++ b/client.cpp @@ -260,8 +260,19 @@ std::string Client::repr() return a.str(); } +/** + * @brief Client::keepAliveExpired + * @return + * + * [MQTT-3.1.2-24]: "If the Keep Alive value is non-zero and the Server does not receive a Control Packet from the + * Client within one and a half times the Keep Alive time period, it MUST disconnect the Network Connection to + * the Client as if the network had failed." + */ bool Client::keepAliveExpired() { + if (keepalive == 0) + return false; + if (!authenticated) return lastActivity + 20 < time(NULL); -- libgit2 0.21.4