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

@@ -40,6 +40,34 @@ test(local_client_should_unregister_when_destroyed)
assertEqual(broker.clientsCount(), (size_t)0);
}
test(local_client_do_not_disconnect_after_publishing)
{
set_millis(0);
MqttBroker broker(1883);
MqttClient client(&broker, "client");
MqttClient sender(&broker, "sender");
broker.loop();
client.subscribe("#");
client.subscribe("test");
client.setCallback(onPublish);
assertEqual(broker.clientsCount(), (size_t)2);
sender.publish("test", "value");
broker.loop();
add_seconds(60);
client.loop();
sender.loop();
broker.loop();
assertEqual(broker.clientsCount(), (size_t)2);
assertEqual(sender.connected(), true);
assertEqual(client.connected(), true);
assertEqual(published.size(), (size_t)1); // client has received something
}
#if 0
test(local_connect)
{