Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext
boost::mqtt5::mqtt_client::async_receive

Asynchronously receive an Application Message.

Synopsis
template<
    typename CompletionToken = typename asio::default_completion_token<boost::mqtt5::mqtt_client::executor_type>::type>
decltype(auto)
async_receive(
    CompletionToken&& token = {});
Description

The Client will receive and complete deliveries for all the PUBLISH packets received from the Broker throughout its lifetime. The Client will store them internally in the order they were delivered. Calling this function will attempt to receive an Application Message from internal storage.

See Also

mqtt_client::async_subscribe

Parameters

Name

Description

token

Completion token that will be used to produce a completion handler. The handler will be invoked when the operation completes. On immediate completion, invocation of the handler will be performed in a manner equivalent to using boost::asio::post.

Handler signature

The handler signature for this operation:

void (
    boost::mqtt5::error_code, // Result of operation.
    std::string,    // Topic, the origin of the Application Message.
    std::string,    // Payload, the content of the Application Message.
    boost::mqtt5::publish_props, // Properties received in the PUBLISH packet.
)
Completion condition

The asynchronous operation will complete when one of the following conditions is true:

Error codes

The list of all possible error codes that this operation can finish with:

Refer to the section on Error handling to find the underlying causes for each error code.

Per-Operation Cancellation

This asynchronous operation supports cancellation for the following boost::asio::cancellation_type values:


PrevUpHomeNext