Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext
boost::mqtt5::mqtt_client::async_disconnect (2 of 2 overloads)

Disconnect the Client by sending a DISCONNECT packet with a Reason Code of reason_codes.normal_disconnection. This function has terminal effects.

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

The Client will attempt to send a DISCONNECT packet to the Broker with a Reason Code describing the reason for disconnection. If the DISCONNECT packet is successfully transmitted, or if 5 seconds elapsed without a successful send, the Client will terminate the connection.

Attention

This function has terminal effects and will close the Client. See mqtt_client::cancel.

Parameters

Name

Description

token

Completion token that will be used to produce a completion handler. The handler will be invoked when the operation completes.

Handler signature

The handler signature for this operation:

void (
    boost::mqtt5::error_code // Result of operation.
)
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