Skip to content

Commit 9b84c7b

Browse files
committed
Wait for all messages to be received in subscribe publish sample
Fixes #73
1 parent b5fc155 commit 9b84c7b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

samples/linux/subscribe_publish_sample/subscribe_publish_sample.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,10 @@ int main(int argc, char **argv) {
240240
publishCount--;
241241
}
242242

243+
if(publishCount == 0) {
244+
break;
245+
}
246+
243247
sprintf(cPayload, "%s : %d ", "hello from SDK QOS1", i++);
244248
paramsQOS1.payloadLen = strlen(cPayload);
245249
rc = aws_iot_mqtt_publish(&client, "sdkTest/sub", 11, &paramsQOS1);
@@ -252,6 +256,9 @@ int main(int argc, char **argv) {
252256
}
253257
}
254258

259+
// Wait for all the messages to be received
260+
aws_iot_mqtt_yield(&client, 100);
261+
255262
if(SUCCESS != rc) {
256263
IOT_ERROR("An error occurred in the loop.\n");
257264
} else {

0 commit comments

Comments
 (0)