![]() |
Home | Libraries | People | FAQ | More |
Disconnect the Client by sending a DISCONNECT
packet with a Reason
Code of reason_codes.normal_disconnection. This function has terminal
effects.
template<
typename CompletionToken = typename asio::default_completion_token<boost::mqtt5::mqtt_client::executor_type
>::type>
decltype(auto)
async_disconnect(
CompletionToken&& token = {});
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.
This function has terminal effects and will close the Client. See mqtt_client::cancel
.
Name |
Description |
---|---|
|
Completion token that will be used to produce a completion handler. The handler will be invoked when the operation completes. |
The handler signature for this operation:
void (
boost::mqtt5::error_code
// Result of operation.
)
The asynchronous operation will complete when one of the following conditions is true:
DISCONNECT
packet, regardless
of whether the sending was successful or not.
boost::mqtt5::error_code
in
the handler.
The list of all possible error codes that this operation can finish with:
boost::system::errc::errc_t::success
boost::asio::error::operation_aborted
[footnote This
error code can appear if the Client fails to send the DISCONNECT
packet to the
Server. Regardless, the connection to the Server is terminated, and
the Client is cancelled. ]
boost::mqtt5::client::error::malformed_packet
Refer to the section on Error handling
to find the underlying causes for each error code.
This asynchronous operation supports cancellation for the following
boost::asio::cancellation_type
values:
cancellation_type::terminal
- invokes mqtt_client::cancel