Commit 1b9eed1755bc361706f0591d55d2bd334c5d25e4
1 parent
60f1de87
Support disabling keep-alives
Showing
1 changed file
with
11 additions
and
0 deletions
client.cpp
| @@ -260,8 +260,19 @@ std::string Client::repr() | @@ -260,8 +260,19 @@ std::string Client::repr() | ||
| 260 | return a.str(); | 260 | return a.str(); |
| 261 | } | 261 | } |
| 262 | 262 | ||
| 263 | +/** | ||
| 264 | + * @brief Client::keepAliveExpired | ||
| 265 | + * @return | ||
| 266 | + * | ||
| 267 | + * [MQTT-3.1.2-24]: "If the Keep Alive value is non-zero and the Server does not receive a Control Packet from the | ||
| 268 | + * Client within one and a half times the Keep Alive time period, it MUST disconnect the Network Connection to | ||
| 269 | + * the Client as if the network had failed." | ||
| 270 | + */ | ||
| 263 | bool Client::keepAliveExpired() | 271 | bool Client::keepAliveExpired() |
| 264 | { | 272 | { |
| 273 | + if (keepalive == 0) | ||
| 274 | + return false; | ||
| 275 | + | ||
| 265 | if (!authenticated) | 276 | if (!authenticated) |
| 266 | return lastActivity + 20 < time(NULL); | 277 | return lastActivity + 20 < time(NULL); |
| 267 | 278 |