Skip to content

Commit

Permalink
Wait for all messages to be received in subscribe publish sample
Browse files Browse the repository at this point in the history
Fixes #73
  • Loading branch information
vareddy committed Oct 12, 2017
1 parent b5fc155 commit 9b84c7b
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,10 @@ int main(int argc, char **argv) {
publishCount--;
}

if(publishCount == 0) {
break;
}

sprintf(cPayload, "%s : %d ", "hello from SDK QOS1", i++);
paramsQOS1.payloadLen = strlen(cPayload);
rc = aws_iot_mqtt_publish(&client, "sdkTest/sub", 11, &paramsQOS1);
Expand All @@ -252,6 +256,9 @@ int main(int argc, char **argv) {
}
}

// Wait for all the messages to be received
aws_iot_mqtt_yield(&client, 100);

if(SUCCESS != rc) {
IOT_ERROR("An error occurred in the loop.\n");
} else {
Expand Down

0 comments on commit 9b84c7b

Please sign in to comment.