| Home | Libraries | People | FAQ | More

#### boost::mqtt5::mqtt_client

MQTT client used to connect and communicate with a Broker.

##### Synopsis

Defined in header `<boost/mqtt5/mqtt_client.hpp>`

    template<
        typename StreamType,
        typename TlsContext = std::monostate,
        typename LoggerType = noop_logger>
    class mqtt_client;

##### Types

Name | Description
--- | ---
executor_type | The executor type associated with the client.
rebind_executor | Rebinds the client type to another executor.

##### Member Functions

Name | Description
--- | ---
async_disconnect | Disconnect the Client by sending a `DISCONNECT` packet with a specified Reason Code. This function has terminal effects. — Disconnect the Client by sending a `DISCONNECT` packet with a Reason Code of reason_codes.normal_disconnection. This function has terminal effects.
async_publish | Send a `PUBLISH` packet to Broker to transport an Application Message.
async_receive | Asynchronously receive an Application Message.
async_run | Start the Client.
async_subscribe | Send a `SUBSCRIBE` packet to Broker to create a Subscription to one or more Topics of interest. — Send a `SUBSCRIBE` packet to Broker to create a Subscription to one Topic of interest.
async_unsubscribe | Send an `UNSUBSCRIBE` packet to Broker to unsubscribe from one or more Topics. — Send an `UNSUBSCRIBE` packet to Broker to unsubscribe from one Topic.
authenticator | Assign an authenticator that the Client will use for `Enhanced Authentication` on every connect to a Broker. Re-authentication can be initiated by calling `re_authenticate`.
brokers | Assign a list of Brokers that the Client will attempt to connect to.
cancel | Cancel all asynchronous operations. This function has terminal effects.
connack_properties | Retrieves the `boost::mqtt5::connack_props` from the last `CONNACK` packet received.
connack_property | Retrieves the value of a specific property from the last `CONNACK` packet received.
connect_properties | Assign `boost::mqtt5::connect_props` that will be sent in a `CONNECT` packet.
connect_property | Assign a property that will be sent in a `CONNECT` packet.
credentials | Assign credentials that will be used to connect to a Broker.
get_executor | Get the executor associated with the object.
keep_alive | Assign the maximum time interval that is permitted to elapse between two transmissions from the Client.
mqtt_client [constructor] | Constructs a Client with given parameters. — Move-construct an mqtt_client from another.
operator= | Move assignment operator.
re_authenticate | Initiates `Re-authentication` using the authenticator given in the `authenticator` method.
tls_context | Get the context object used in TLS/SSL connection.
will | Assign a `will` Message.
~mqtt_client [destructor] | Destructor.

##### Template Parameters

Type | Description
--- | ---
`StreamType` | Type of the underlying transport protocol used to transfer the stream of bytes between the Client and the Broker. The transport must be ordered and lossless.
`TlsContext` | Type of the context object used in TLS/SSL connections.
`LoggerType` | Type of object used to log events within the Client.

##### Thread safety

Distinct objects: safe.

Shared objects: unsafe.

This class is not thread-safe. The application must also ensure that all asynchronous operations are performed within the same implicit or explicit strand.

Convenience header `<boost/mqtt5.hpp>`