MqttClient - fix local disconnect after pulish + ka

This commit is contained in:
hsaturn
2023-01-03 04:00:59 +01:00
parent 09e3a3e45f
commit baffda8a6d
2 changed files with 33 additions and 2 deletions

View File

@@ -55,7 +55,10 @@ MqttClient::MqttClient(MqttBroker* local_broker, TcpClient* new_client)
MqttClient::MqttClient(MqttBroker* local_broker, const std::string& id)
: local_broker(local_broker), clientId(id)
{
if (local_broker) local_broker->addClient(this);
alive = 0;
keep_alive = 0;
if (local_broker) local_broker->addClient(this);
}
MqttClient::~MqttClient()
@@ -281,7 +284,7 @@ void MqttClient::clientAlive(uint32_t more_seconds)
void MqttClient::loop()
{
if (alive && (millis() > alive))
if (keep_alive && (millis() >= alive))
{
if (local_broker)
{