Skip to content

Commit

Permalink
add debug prints
Browse files Browse the repository at this point in the history
  • Loading branch information
alfred2g committed Dec 20, 2023
1 parent 1d009c9 commit ff2c27d
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions tests/Mqtt5ClientTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,18 @@ static void s_setupConnectionLifeCycle(
{
mqtt5Options.WithClientConnectionSuccessCallback(
[&connectionPromise, clientName](const OnConnectionSuccessEventData &) {
printf("[MQTT5]%s Connection Success.", clientName);
printf("[MQTT5]%s Connection Success.\n", clientName);
connectionPromise.set_value(true);
});

mqtt5Options.WithClientConnectionFailureCallback(
[&connectionPromise, clientName](const OnConnectionFailureEventData &eventData) {
printf("[MQTT5]%s Connection failed with error : %s", clientName, aws_error_debug_str(eventData.errorCode));
printf("[MQTT5]%s Connection failed with error : %s\n", clientName, aws_error_debug_str(eventData.errorCode));
connectionPromise.set_value(false);
});

mqtt5Options.WithClientStoppedCallback([&stoppedPromise, clientName](const OnStoppedEventData &) {
printf("[MQTT5]%s Stopped", clientName);
printf("[MQTT5]%s Stopped\n", clientName);
stoppedPromise.set_value();
});
}
Expand Down Expand Up @@ -1977,6 +1977,7 @@ static int s_TestMqtt5SharedSubscriptionTest(Aws::Crt::Allocator *allocator, voi
std::promise<void> client1_received;
auto onMessage_client1 = [&](const PublishReceivedEventData &eventData) -> int {
String topic = eventData.publishPacket->getTopic();
printf("========= packet 1 received %s\n", topic.c_str());
if (topic == TEST_TOPIC)
{
ByteCursor payload = eventData.publishPacket->getPayload();
Expand All @@ -1985,7 +1986,7 @@ static int s_TestMqtt5SharedSubscriptionTest(Aws::Crt::Allocator *allocator, voi
ASSERT_TRUE(message_int < MESSAGE_NUMBER);
++receivedMessages[message_int];
client1_messages++;
if (client1_messages >= 5)
if (client1_messages == 5)
{
fprintf(stderr, "client 1 future set\n");
client1_received.set_value();
Expand All @@ -2006,6 +2007,7 @@ static int s_TestMqtt5SharedSubscriptionTest(Aws::Crt::Allocator *allocator, voi
std::promise<void> client2_received;
auto onMessage_client2 = [&](const PublishReceivedEventData &eventData) -> int {
String topic = eventData.publishPacket->getTopic();
printf("========= packet 2 received %s\n", topic.c_str());
if (topic == TEST_TOPIC)
{
ByteCursor payload = eventData.publishPacket->getPayload();
Expand All @@ -2014,7 +2016,7 @@ static int s_TestMqtt5SharedSubscriptionTest(Aws::Crt::Allocator *allocator, voi
ASSERT_TRUE(message_int < MESSAGE_NUMBER);
++receivedMessages[message_int];
client2_messages++;
if (client2_messages >= 5)
if (client2_messages == 5)
{
fprintf(stderr, " client 2 future set\n");
client2_received.set_value();
Expand Down

0 comments on commit ff2c27d

Please sign in to comment.