Try to fix alive problem
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
# See https://github.com/bxparks/EpoxyDuino for documentation about this
|
||||
# Makefile to compile and run Arduino programs natively on Linux or MacOS.
|
||||
|
||||
EXTRA_CXXFLAGS=-g3 -O0
|
||||
EXTRA_CXXFLAGS=-g3 -O0 -DTINY_MQTT_DEFAULT_ALIVE=1
|
||||
|
||||
# Remove flto flag from EpoxyDuino (too many <optimized out>)
|
||||
CXXFLAGS = -Wextra -Wall -std=gnu++11 -fno-exceptions -fno-threadsafe-statics
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
MqttBroker broker(1883);
|
||||
|
||||
std::map<std::string, std::map<Topic, int>> published; // map[client_id] => map[topic] = count
|
||||
|
||||
@@ -31,6 +30,7 @@ void onPublish(const MqttClient* srce, const Topic& topic, const char* payload,
|
||||
|
||||
test(local_client_should_unregister_when_destroyed)
|
||||
{
|
||||
MqttBroker broker(1883);
|
||||
assertEqual(broker.clientsCount(), (size_t)0);
|
||||
{
|
||||
assertEqual(broker.clientsCount(), (size_t)0); // Ensure client is not yet connected
|
||||
@@ -40,6 +40,18 @@ test(local_client_should_unregister_when_destroyed)
|
||||
assertEqual(broker.clientsCount(), (size_t)0);
|
||||
}
|
||||
|
||||
test(local_client_alive)
|
||||
{
|
||||
MqttBroker broker(1883);
|
||||
MqttClient client(&broker);
|
||||
for(int i=0; i<10; i++)
|
||||
{
|
||||
assertEqual(broker.clientsCount(), (size_t)1); // Ensure client is now connected
|
||||
broker.loop();
|
||||
usleep(TINY_MQTT_DEFAULT_ALIVE*1000000/2);
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
test(local_connect)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user