Skip to content

Commit

Permalink
remove not needed peek
Browse files Browse the repository at this point in the history
  • Loading branch information
256dpi committed Mar 22, 2018
1 parent 8cd645f commit 57756f5
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions examples/async.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,13 @@ static void *thread(void *_) {
// lock mutex
pthread_mutex_lock(&mutex);

// process incoming data
// process incoming data if available
if (data) {
// get available data
size_t available = 0;
err = lwmqtt_unix_network_peek(&network, &available);
err = lwmqtt_yield(&client, 0, COMMAND_TIMEOUT);
if (err != LWMQTT_SUCCESS) {
printf("failed lwmqtt_unix_network_peek: %d\n", err);
printf("failed lwmqtt_yield: %d\n", err);
exit(1);
}

// process data
if (available > 0) {
err = lwmqtt_yield(&client, available, COMMAND_TIMEOUT);
if (err != LWMQTT_SUCCESS) {
printf("failed lwmqtt_yield: %d\n", err);
exit(1);
}
}
}

// keep connection alive
Expand Down

0 comments on commit 57756f5

Please sign in to comment.