Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext
boost::mqtt5::mqtt_client::async_unsubscribe (1 of 2 overloads)

Send an UNSUBSCRIBE packet to Broker to unsubscribe from one or more Topics.

Synopsis
template<
    typename CompletionToken = typename asio::default_completion_token<boost::mqtt5::mqtt_client::executor_type>::type>
decltype(auto)
async_unsubscribe(
    const std::vector< std::string >& topics,
    const unsubscribe_props& props,
    CompletionToken&& token = {});
Remarks

The Client may still receive residual Application Messages through the mqtt_client::async_receive function from Topics the Client just unsubscribed to.

Parameters

Name

Description

topics

List of Topics to unsubscribe from.

props

An instance of boost::mqtt5::unsubscribe_props.

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::async_immediate.

Handler signature

The handler signature for this operation:

void (
    boost::mqtt5::error_code, // Result of operation.
    std::vector<boost::mqtt5::reason_code>,  // Vector of Reason Codes indicating
                                   // the result of unsubscribe operation
                                   // for each Topic in the UNSUBSCRIBE packet.
    boost::mqtt5::unsuback_props, // Properties received in the UNSUBACK 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