mqtt_await_messages

Waits until there is at least one message in the inbox.

C Language

size_t mqtt_await_messages( MQTT handle, int timeoutMsec);

Example MQTT Vuser Functions

Arguments

Name Comments
handle The MQTT client handle returned by mqtt_create.
timeoutMsec Number of milliseconds or MQTT_DEFAULT.
Default: The timeout value in the runtime settings.

General

mqtt_await_messages waits until there is at least one message in the inbox. The script run continues after there is a message or after the wait times out.

If invalid arguments are passed, the Vuser aborts, even if Continue on error is set.

Return Values

The number of messages in the inbox. 0 if timed out.

Parameterization

Standard parameterization is not available for this function.

Example

// wait for messages to arrive and print the message count

size_t messageCount = mqtt_await_messages(client, MQTT_DEFAULT);

lr_message("There are %d pending messages", messageCount);

if (messageCount > 0) {

// handle messages

}