mqtt_cpp
Classes | Public Types | Public Member Functions | Protected Member Functions | Friends | List of all members
MQTT_NS::client< Socket, PacketIdBytes > Class Template Reference

#include <client.hpp>

Inheritance diagram for MQTT_NS::client< Socket, PacketIdBytes >:
Inheritance graph
[legend]
Collaboration diagram for MQTT_NS::client< Socket, PacketIdBytes >:
Collaboration graph
[legend]

Classes

struct  constructor_access
 

Public Types

using async_handler_t = typename base::async_handler_t
 
- Public Types inherited from MQTT_NS::endpoint< std::mutex, std::lock_guard, 2 >
using async_handler_t = std::function< void(error_code ec)>
 
using packet_id_t = typename packet_id_type< PacketIdBytes >::type
 

Public Member Functions

template<typename ... Args>
 client (constructor_access, Args &&... args)
 
void set_host (std::string host)
 Set host. More...
 
void set_port (std::string port)
 Set port. More...
 
void set_client_id (std::string id)
 Set client id. More...
 
std::string const & get_client_id () const
 Get the client id. More...
 
void set_clean_session (bool cs)
 Set clean session. More...
 
void set_clean_start (bool cs)
 Set clean start. More...
 
void set_user_name (std::string name)
 Set username. More...
 
void set_password (std::string password)
 Set password. More...
 
void set_will (will w)
 Set will. More...
 
template<typename ... Args>
void set_will (Args &&... args)
 
void set_keep_alive_sec (std::uint16_t keep_alive_sec, std::chrono::steady_clock::duration ping)
 Set a keep alive second and a ping duration. More...
 
void set_keep_alive_sec_ping_ms (std::uint16_t keep_alive_sec, std::size_t ping_ms)
 Set a keep alive second and a ping milli seconds. More...
 
void set_keep_alive_sec (std::uint16_t keep_alive_sec)
 Set a keep alive second and a ping milli seconds. More...
 
void connect (any session_life_keeper=any())
 Connect to a broker Before calling connect(), call set_xxx member functions to configure the connection. More...
 
void connect (boost::system::error_code &ec, any session_life_keeper=any())
 Connect to a broker Before calling connect(), call set_xxx member functions to configure the connection. More...
 
void connect (v5::properties props, any session_life_keeper=any())
 Connect to a broker Before calling connect(), call set_xxx member functions to configure the connection. More...
 
void connect (v5::properties props, boost::system::error_code &ec, any session_life_keeper=any())
 Connect to a broker Before calling connect(), call set_xxx member functions to configure the connection. More...
 
void connect (std::shared_ptr< Socket > &&socket, any session_life_keeper=any())
 Connect to a broker Before calling connect(), call set_xxx member functions to configure the connection. More...
 
void connect (std::shared_ptr< Socket > &&socket, boost::system::error_code &ec, any session_life_keeper=any())
 Connect to a broker Before calling connect(), call set_xxx member functions to configure the connection. More...
 
void connect (std::shared_ptr< Socket > &&socket, v5::properties props, any session_life_keeper=any())
 Connect to a broker Before calling connect(), call set_xxx member functions to configure the connection. More...
 
void connect (std::shared_ptr< Socket > &&socket, v5::properties props, boost::system::error_code &ec, any session_life_keeper=any())
 Connect to a broker Before calling connect(), call set_xxx member functions to configure the connection. More...
 
void async_connect ()
 Connect to a broker Before calling connect(), call set_xxx member functions to configure the connection. More...
 
template<typename T >
std::enable_if_t< !std::is_convertible< T, async_handler_t >::value > async_connect (T session_life_keeper)
 Connect to a broker Before calling connect(), call set_xxx member functions to configure the connection. More...
 
void async_connect (async_handler_t func)
 Connect to a broker Before calling connect(), call set_xxx member functions to configure the connection. More...
 
void async_connect (any session_life_keeper, async_handler_t func)
 Connect to a broker Before calling connect(), call set_xxx member functions to configure the connection. More...
 
template<typename T >
std::enable_if_t< !std::is_convertible< T, async_handler_t >::value > async_connect (v5::properties props, T session_life_keeper)
 Connect to a broker Before calling connect(), call set_xxx member functions to configure the connection. More...
 
void async_connect (v5::properties props, async_handler_t func)
 Connect to a broker Before calling connect(), call set_xxx member functions to configure the connection. More...
 
void async_connect (v5::properties props, any session_life_keeper, async_handler_t func)
 Connect to a broker Before calling connect(), call set_xxx member functions to configure the connection. More...
 
void async_connect (std::shared_ptr< Socket > &&socket)
 Connect to a broker Before calling connect(), call set_xxx member functions to configure the connection. More...
 
template<typename T >
std::enable_if_t< !std::is_convertible< T, async_handler_t >::value > async_connect (std::shared_ptr< Socket > &&socket, T session_life_keeper)
 Connect to a broker Before calling connect(), call set_xxx member functions to configure the connection. More...
 
void async_connect (std::shared_ptr< Socket > &&socket, async_handler_t func)
 Connect to a broker Before calling connect(), call set_xxx member functions to configure the connection. More...
 
void async_connect (std::shared_ptr< Socket > &&socket, any session_life_keeper, async_handler_t func)
 Connect to a broker Before calling connect(), call set_xxx member functions to configure the connection. More...
 
void async_connect (std::shared_ptr< Socket > &&socket, v5::properties props)
 Connect to a broker Before calling connect(), call set_xxx member functions to configure the connection. More...
 
template<typename T >
std::enable_if_t< !std::is_convertible< T, async_handler_t >::value > async_connect (std::shared_ptr< Socket > &&socket, v5::properties props, T session_life_keeper)
 Connect to a broker Before calling connect(), call set_xxx member functions to configure the connection. More...
 
void async_connect (std::shared_ptr< Socket > &&socket, v5::properties props, async_handler_t func)
 Connect to a broker Before calling connect(), call set_xxx member functions to configure the connection. More...
 
void async_connect (std::shared_ptr< Socket > &&socket, v5::properties props, any session_life_keeper, async_handler_t func)
 Connect to a broker Before calling connect(), call set_xxx member functions to configure the connection. More...
 
void disconnect (std::chrono::steady_clock::duration timeout, v5::disconnect_reason_code reason_code=v5::disconnect_reason_code::normal_disconnection, v5::properties props={})
 Disconnect Send a disconnect packet to the connected broker. It is a clean disconnecting sequence. The broker disconnects the endpoint after receives the disconnect packet.
When the endpoint disconnects using disconnect(), a will won't send.
See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901205
More...
 
void disconnect (v5::disconnect_reason_code reason_code=v5::disconnect_reason_code::normal_disconnection, v5::properties props={})
 Disconnect Send a disconnect packet to the connected broker. It is a clean disconnecting sequence. The broker disconnects the endpoint after receives the disconnect packet.
When the endpoint disconnects using disconnect(), a will won't send.
See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901205
More...
 
void async_disconnect (std::chrono::steady_clock::duration timeout, async_handler_t func=async_handler_t())
 Disconnect Send a disconnect packet to the connected broker. It is a clean disconnecting sequence. The broker disconnects the endpoint after receives the disconnect packet.
When the endpoint disconnects using disconnect(), a will won't send.
See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901205
More...
 
void async_disconnect (std::chrono::steady_clock::duration timeout, v5::disconnect_reason_code reason_code, v5::properties props, async_handler_t func=async_handler_t())
 Disconnect Send a disconnect packet to the connected broker. It is a clean disconnecting sequence. The broker disconnects the endpoint after receives the disconnect packet.
When the endpoint disconnects using disconnect(), a will won't send.
See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901205
More...
 
void async_disconnect (async_handler_t func=async_handler_t())
 Disconnect Send a disconnect packet to the connected broker. It is a clean disconnecting sequence. The broker disconnects the endpoint after receives the disconnect packet.
When the endpoint disconnects using disconnect(), a will won't send.
See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901205
More...
 
void async_disconnect (v5::disconnect_reason_code reason_code, v5::properties props, async_handler_t func=async_handler_t())
 Disconnect Send a disconnect packet to the connected broker. It is a clean disconnecting sequence. The broker disconnects the endpoint after receives the disconnect packet.
When the endpoint disconnects using disconnect(), a will won't send.
See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901205
More...
 
void force_disconnect ()
 Disconnect by endpoint Force disconnect. It is not a clean disconnect sequence.
When the endpoint disconnects using force_disconnect(), a will will send.
More...
 
void set_async_pingreq (bool b)
 Set pingreq message sending mode. More...
 
std::shared_ptr< Socket > const & socket () const
 
std::shared_ptr< Socket > & socket ()
 
- Public Member Functions inherited from MQTT_NS::endpoint< std::mutex, std::lock_guard, 2 >
 endpoint (as::io_context &ioc, protocol_version version=protocol_version::undetermined, bool async_send_store=false)
 Constructor for client. More...
 
 endpoint (as::io_context &ioc, std::shared_ptr< MQTT_NS::socket > socket, protocol_version version=protocol_version::undetermined, bool async_send_store=false)
 Constructor for server. socket should have already been connected with another endpoint. More...
 
 endpoint (this_type const &)=delete
 
 endpoint (this_type &&)=delete
 
endpointoperator= (this_type const &)=delete
 
endpointoperator= (this_type &&)=delete
 
bool clean_session () const
 Get clean session. More...
 
bool clean_start () const
 Get clean start. More...
 
std::size_t get_total_bytes_received () const
 get_total_bytes_received More...
 
std::size_t get_total_bytes_sent () const
 get_total_bytes_sent More...
 
void set_auto_pub_response (bool b=true, bool async=true)
 Set auto publish response mode. More...
 
void set_auto_map_topic_alias_send (bool b=true)
 Set topic alias send auto mapping enable flag. More...
 
void set_auto_replace_topic_alias_send (bool b=true)
 Set topic alias send auto replacing enable flag. More...
 
void set_packet_bulk_read_limit (std::size_t size)
 
void set_props_bulk_read_limit (std::size_t size)
 
void set_topic_alias_maximum (topic_alias_t max)
 set topic alias maximum for receiving More...
 
void start_session (any session_life_keeper=any())
 start session with a connected endpoint. More...
 
std::enable_if_t< ! std::is_convertible< std::decay_t< T >, packet_id_t >::value, packet_id_tpublish (T &&t, Params &&... params)
 Publish. More...
 
void publish (packet_id_t packet_id, std::string topic_name, std::string contents, publish_options pubopts={}, v5::properties props={}, any life_keeper={})
 Publish with already acquired packet identifier. More...
 
std::enable_if< as::is_const_buffer_sequence< ConstBufferSequence >::value >::type publish (packet_id_t packet_id, as::const_buffer topic_name, ConstBufferSequence contents, publish_options pubopts, v5::properties props, any life_keeper)
 Publish with already acquired packet identifier. More...
 
std::enable_if< as::is_const_buffer_sequence< ConstBufferSequence >::value >::type publish (packet_id_t packet_id, as::const_buffer topic_name, ConstBufferSequence contents, publish_options pubopts, any life_keeper)
 Publish with already acquired packet identifier. More...
 
std::enable_if< is_buffer_sequence< BufferSequence >::value >::type publish (packet_id_t packet_id, buffer topic_name, BufferSequence contents, publish_options pubopts={}, any life_keeper={})
 Publish with already acquired packet identifier. More...
 
std::enable_if< is_buffer_sequence< BufferSequence >::value >::type publish (packet_id_t packet_id, buffer topic_name, BufferSequence contents, publish_options pubopts, v5::properties props, any life_keeper={})
 Publish with already acquired packet identifier. More...
 
std::enable_if_t< ! std::is_convertible< std::decay_t< T >, packet_id_t >::value, packet_id_tsubscribe (T &&t, Params &&... params)
 Subscribe. More...
 
void subscribe (packet_id_t packet_id, string_view topic_filter, subscribe_options option, v5::properties props={})
 Subscribe with already acquired packet identifier. More...
 
void subscribe (packet_id_t packet_id, as::const_buffer topic_filter, subscribe_options option, v5::properties props={})
 Subscribe with already acquired packet identifier. More...
 
void subscribe (packet_id_t packet_id, std::vector< std::tuple< string_view, subscribe_options >> params, v5::properties props={})
 Subscribe with already acquired packet identifier. More...
 
void subscribe (packet_id_t packet_id, std::vector< std::tuple< buffer, subscribe_options >> params, v5::properties props={})
 Subscribe with already acquired packet identifier. More...
 
std::enable_if_t< ! std::is_convertible< std::decay_t< T >, packet_id_t >::value, packet_id_tunsubscribe (T &&t, Params &&... params)
 Unsubscribe. More...
 
void unsubscribe (packet_id_t packet_id, string_view topic_filter, v5::properties props={})
 Unsubscribe with already acquired packet identifier. More...
 
void unsubscribe (packet_id_t packet_id, as::const_buffer topic_filter, v5::properties props={})
 Unsubscribe with already acquired packet identifier. More...
 
void unsubscribe (packet_id_t packet_id, std::vector< string_view > params, v5::properties props={})
 Unsubscribe with already acquired packet identifier. More...
 
void unsubscribe (packet_id_t packet_id, std::vector< as::const_buffer > params, v5::properties props={})
 Unsubscribe with already acquired packet identifier. More...
 
void unsubscribe (packet_id_t packet_id, std::vector< buffer > params, v5::properties props={})
 Unsubscribe with already acquired packet identifier. More...
 
void disconnect (v5::disconnect_reason_code reason=v5::disconnect_reason_code::normal_disconnection, v5::properties props={})
 Disconnect Send a disconnect packet to the connected broker. It is a clean disconnecting sequence. The broker disconnects the endpoint after receives the disconnect packet.
When the endpoint disconnects using disconnect(), a will won't send.
See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901205
More...
 
void force_disconnect ()
 Disconnect by endpoint Force disconnect. It is not a clean disconnect sequence.
When the endpoint disconnects using force_disconnect(), a will will send.
More...
 
void pingreq ()
 Send pingreq packet. See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901195. More...
 
void pingresp ()
 Send pingresp packet. This function is for broker. See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901200. More...
 
void auth (v5::auth_reason_code reason_code=v5::auth_reason_code::success, v5::properties props={})
 Send auth packet. See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc398718086. More...
 
void connect (std::string const &client_id, optional< std::string > const &user_name, optional< std::string > const &password, optional< will > w, std::uint16_t keep_alive_sec, v5::properties props={})
 Send connect packet. More...
 
void connect (buffer client_id, optional< buffer > user_name, optional< buffer > password, optional< will > w, std::uint16_t keep_alive_sec, v5::properties props={})
 Send connect packet. More...
 
void connack (bool session_present, variant< connect_return_code, v5::connect_reason_code > reason_code, v5::properties props={})
 Send connack packet. This function is for broker. More...
 
void puback (packet_id_t packet_id, v5::puback_reason_code reason_code=v5::puback_reason_code::success, v5::properties props={})
 Send puback packet. More...
 
void pubrec (packet_id_t packet_id, v5::pubrec_reason_code reason_code=v5::pubrec_reason_code::success, v5::properties props={})
 Send packet. More...
 
void pubrel (packet_id_t packet_id, v5::pubrel_reason_code reason_code=v5::pubrel_reason_code::success, v5::properties props={}, any life_keeper={})
 Send pubrel packet. More...
 
void pubcomp (packet_id_t packet_id, v5::pubcomp_reason_code reason_code=v5::pubcomp_reason_code::success, v5::properties props={})
 Send pubcomp packet. More...
 
void suback (packet_id_t packet_id, variant< suback_return_code, v5::suback_reason_code > reason, v5::properties props={})
 Send suback packet. This function is for broker. More...
 
void suback (packet_id_t packet_id, variant< std::vector< suback_return_code >, std::vector< v5::suback_reason_code >> reasons, v5::properties props={})
 Send suback packet. This function is for broker. More...
 
void unsuback (packet_id_t packet_id)
 Send unsuback packet. This function is for broker. More...
 
void unsuback (packet_id_t packet_id, v5::unsuback_reason_code reason, v5::properties props={})
 Send unsuback packet. This function is for broker. More...
 
void unsuback (packet_id_t packet_id, std::vector< v5::unsuback_reason_code > reasons, v5::properties props={})
 Send unsuback packet. This function is for broker. More...
 
std::enable_if_t< ! std::is_convertible< std::decay_t< T >, packet_id_t >::value > async_publish (T &&t, Params &&... params)
 Publish. More...
 
void async_publish (packet_id_t packet_id, std::string topic_name, std::string contents, publish_options pubopts={}, async_handler_t func={})
 Publish with a manual set packet identifier. More...
 
void async_publish (packet_id_t packet_id, std::string topic_name, std::string contents, publish_options pubopts, v5::properties props, any life_keeper={}, async_handler_t func={})
 Publish with a manual set packet identifier. More...
 
std::enable_if< as::is_const_buffer_sequence< ConstBufferSequence >::value >::type async_publish (packet_id_t packet_id, as::const_buffer topic_name, ConstBufferSequence contents, publish_options pubopts={}, any life_keeper={}, async_handler_t func={})
 Publish with a manual set packet identifier. More...
 
std::enable_if< as::is_const_buffer_sequence< ConstBufferSequence >::value >::type async_publish (packet_id_t packet_id, as::const_buffer topic_name, ConstBufferSequence contents, publish_options pubopts, v5::properties props, any life_keeper={}, async_handler_t func={})
 Publish with a manual set packet identifier. More...
 
std::enable_if< is_buffer_sequence< BufferSequence >::value >::type async_publish (packet_id_t packet_id, buffer topic_name, BufferSequence contents, publish_options pubopts={}, any life_keeper={}, async_handler_t func={})
 Publish with a manual set packet identifier. More...
 
std::enable_if< is_buffer_sequence< BufferSequence >::value >::type async_publish (packet_id_t packet_id, buffer topic_name, BufferSequence contents, publish_options pubopts, v5::properties props, any life_keeper={}, async_handler_t func={})
 Publish with a manual set packet identifier. More...
 
void async_disconnect (async_handler_t func={})
 Disconnect. More...
 
void async_disconnect (v5::disconnect_reason_code reason, v5::properties props, async_handler_t func={})
 Disconnect. More...
 
std::enable_if_t< ! std::is_convertible< std::decay_t< T >, packet_id_t >::value > async_subscribe (T &&t, Params &&... params)
 Subscribe. More...
 
void async_subscribe (packet_id_t packet_id, std::string topic_filter, subscribe_options option, async_handler_t func={})
 Subscribe. More...
 
void async_subscribe (packet_id_t packet_id, std::string topic_filter, subscribe_options option, v5::properties props, async_handler_t func={})
 Subscribe. More...
 
void async_subscribe (packet_id_t packet_id, as::const_buffer topic_filter, subscribe_options option, async_handler_t func)
 Subscribe. More...
 
void async_subscribe (packet_id_t packet_id, as::const_buffer topic_filter, subscribe_options option, v5::properties props, async_handler_t func)
 Subscribe. More...
 
void async_subscribe (packet_id_t packet_id, buffer topic_filter, subscribe_options option, async_handler_t func={})
 Subscribe. More...
 
void async_subscribe (packet_id_t packet_id, buffer topic_filter, subscribe_options option, v5::properties props, async_handler_t func={})
 Subscribe. More...
 
void async_subscribe (packet_id_t packet_id, std::vector< std::tuple< std::string, subscribe_options >> params, async_handler_t func={})
 Subscribe. More...
 
void async_subscribe (packet_id_t packet_id, std::vector< std::tuple< std::string, subscribe_options >> params, v5::properties props, async_handler_t func={})
 Subscribe. More...
 
void async_subscribe (packet_id_t packet_id, std::vector< std::tuple< as::const_buffer, subscribe_options >> params, async_handler_t func)
 Subscribe. More...
 
void async_subscribe (packet_id_t packet_id, std::vector< std::tuple< as::const_buffer, subscribe_options >> params, v5::properties props, async_handler_t func)
 Subscribe. More...
 
void async_subscribe (packet_id_t packet_id, std::vector< std::tuple< buffer, subscribe_options >> params, async_handler_t func={})
 Subscribe. More...
 
void async_subscribe (packet_id_t packet_id, std::vector< std::tuple< buffer, subscribe_options >> params, v5::properties props, async_handler_t func={})
 Subscribe. More...
 
std::enable_if_t< ! std::is_convertible< std::decay_t< T >, packet_id_t >::value > async_unsubscribe (T &&t, Params &&... params)
 Unsubscribe. More...
 
void async_unsubscribe (packet_id_t packet_id, std::string topic_filter, async_handler_t func={})
 Unsubscribe. More...
 
void async_unsubscribe (packet_id_t packet_id, as::const_buffer topic_filter, async_handler_t func)
 Unsubscribe. More...
 
void async_unsubscribe (packet_id_t packet_id, buffer topic_filter, async_handler_t func={})
 Unsubscribe. More...
 
void async_unsubscribe (packet_id_t packet_id, buffer topic_filter, v5::properties props, async_handler_t func={})
 Unsubscribe. More...
 
void async_unsubscribe (packet_id_t packet_id, std::vector< std::string > params, async_handler_t func={})
 Unsubscribe. More...
 
void async_unsubscribe (packet_id_t packet_id, std::vector< std::string > params, v5::properties props, async_handler_t func={})
 Unsubscribe. More...
 
void async_unsubscribe (packet_id_t packet_id, std::vector< as::const_buffer > params, async_handler_t func)
 Unsubscribe. More...
 
void async_unsubscribe (packet_id_t packet_id, std::vector< as::const_buffer > params, v5::properties props, async_handler_t func)
 Unsubscribe. More...
 
void async_unsubscribe (packet_id_t packet_id, std::vector< buffer > params, async_handler_t func={})
 Unsubscribe. More...
 
void async_unsubscribe (packet_id_t packet_id, std::vector< buffer > params, v5::properties props, async_handler_t func={})
 Unsubscribe. More...
 
void async_pingreq (async_handler_t func={})
 Send pingreq packet. More...
 
void async_pingresp (async_handler_t func={})
 Send pingresp packet. This function is for broker. More...
 
void async_auth (v5::auth_reason_code reason_code=v5::auth_reason_code::success, v5::properties props={}, async_handler_t func={})
 Send auth packet. More...
 
void async_connect (buffer client_id, optional< buffer > user_name, optional< buffer > password, optional< will > w, std::uint16_t keep_alive_sec, async_handler_t func={})
 Send connect packet. More...
 
void async_connect (buffer client_id, optional< buffer > user_name, optional< buffer > password, optional< will > w, std::uint16_t keep_alive_sec, v5::properties props, async_handler_t func={})
 Send connect packet. More...
 
void async_connack (bool session_present, variant< connect_return_code, v5::connect_reason_code > reason_code, async_handler_t func={})
 Send connack packet. This function is for broker. More...
 
void async_connack (bool session_present, variant< connect_return_code, v5::connect_reason_code > reason_code, v5::properties props, async_handler_t func={})
 Send connack packet. This function is for broker. More...
 
void async_puback (packet_id_t packet_id, async_handler_t func={})
 Send puback packet. More...
 
void async_puback (packet_id_t packet_id, v5::puback_reason_code reason_code, v5::properties props, async_handler_t func={})
 Send puback packet. More...
 
void async_pubrec (packet_id_t packet_id, async_handler_t func={})
 Send pubrec packet. More...
 
void async_pubrec (packet_id_t packet_id, v5::pubrec_reason_code reason_code, v5::properties props, async_handler_t func={})
 Send pubrec packet. More...
 
void async_pubrel (packet_id_t packet_id, async_handler_t func={})
 Send pubrel packet. More...
 
void async_pubrel (packet_id_t packet_id, v5::pubrel_reason_code reason_code, v5::properties props={}, any life_keeper={}, async_handler_t func={})
 Send pubrel packet. More...
 
void async_pubcomp (packet_id_t packet_id, async_handler_t func={})
 Send pubcomp packet. More...
 
void async_pubcomp (packet_id_t packet_id, v5::pubcomp_reason_code reason_code, v5::properties props, async_handler_t func={})
 Send pubcomp packet. More...
 
void async_suback (packet_id_t packet_id, variant< suback_return_code, v5::suback_reason_code > reason, async_handler_t func={})
 Send suback packet. This function is for broker. More...
 
void async_suback (packet_id_t packet_id, variant< suback_return_code, v5::suback_reason_code > reason, v5::properties props, async_handler_t func={})
 Send suback packet. This function is for broker. More...
 
void async_suback (packet_id_t packet_id, variant< std::vector< suback_return_code >, std::vector< v5::suback_reason_code >> reasons, async_handler_t func={})
 Send suback packet. This function is for broker. More...
 
void async_suback (packet_id_t packet_id, variant< std::vector< suback_return_code >, std::vector< v5::suback_reason_code >> reasons, v5::properties props, async_handler_t func={})
 Send suback packet. This function is for broker. More...
 
void async_unsuback (packet_id_t packet_id, v5::unsuback_reason_code reason, async_handler_t func={})
 Send unsuback packet. This function is for broker. More...
 
void async_unsuback (packet_id_t packet_id, v5::unsuback_reason_code reason, v5::properties props, async_handler_t func={})
 Send unsuback packet. This function is for broker. More...
 
void async_unsuback (packet_id_t packet_id, std::vector< v5::unsuback_reason_code > reasons, async_handler_t func={})
 Send unsuback packet. This function is for broker. More...
 
void async_unsuback (packet_id_t packet_id, std::vector< v5::unsuback_reason_code > reasons, v5::properties props, async_handler_t func={})
 Send unsuback packet. This function is for broker. More...
 
void async_unsuback (packet_id_t packet_id, async_handler_t func={})
 Send ununsuback packet. This function is for broker. More...
 
void clear_stored_publish (packet_id_t packet_id)
 Clear stored publish message that has packet_id. More...
 
void for_each_store (std::function< void(char const *, std::size_t)> const &f)
 Apply f to stored messages. More...
 
void for_each_store (std::function< void(basic_store_message_variant< PacketIdBytes >)> const &f)
 Apply f to stored messages. More...
 
void for_each_store_with_life_keeper (std::function< void(basic_store_message_variant< PacketIdBytes >, any)> const &f)
 Apply f to stored messages. More...
 
packet_id_t acquire_unique_packet_id ()
 Acquire the new unique packet id. If all packet ids are already in use, then throw packet_id_exhausted_error exception. After acquiring the packet id, you can call acquired_* functions. The ownership of packet id is moved to the library. Or you can call release_packet_id to release it. More...
 
optional< packet_id_tacquire_unique_packet_id_no_except ()
 Acquire the new unique packet id. If all packet ids are already in use, then returns nullopt After acquiring the packet id, you can call acquired_* functions. The ownership of packet id is moved to the library. Or you can call release_packet_id to release it. More...
 
bool register_packet_id (packet_id_t packet_id)
 Register packet_id to the library. After registering the packet_id, you can call acquired_* functions. The ownership of packet id is moved to the library. Or you can call release_packet_id to release it. More...
 
void release_packet_id (packet_id_t packet_id)
 Release packet_id. More...
 
std::enable_if_t< std::is_convertible< typename Iterator::value_type, char >::value > restore_serialized_message (Iterator b, Iterator e)
 Restore serialized publish and pubrel messages. This function should be called before connect. More...
 
void restore_serialized_message (basic_publish_message< PacketIdBytes > msg, any life_keeper={})
 Restore serialized publish message. This function should be called before connect. More...
 
void restore_serialized_message (basic_pubrel_message< PacketIdBytes > msg, any life_keeper={})
 Restore serialized pubrel message. This function should be called before connect. More...
 
void restore_serialized_message (basic_store_message_variant< PacketIdBytes > msg, any life_keeper={})
 
std::enable_if_t< std::is_convertible< typename Iterator::value_type, char >::value > restore_v5_serialized_message (Iterator b, Iterator e)
 Restore serialized publish and pubrel messages. This function shouold be called before connect. More...
 
void restore_v5_serialized_message (v5::basic_publish_message< PacketIdBytes > msg, any life_keeper={})
 Restore serialized publish message. This function shouold be called before connect. More...
 
void restore_v5_serialized_message (v5::basic_pubrel_message< PacketIdBytes > msg, any life_keeper={})
 Restore serialized pubrel message. This function shouold be called before connect. More...
 
void send_store_message (basic_store_message_variant< PacketIdBytes > msg, any life_keeper)
 
void async_send_store_message (basic_store_message_variant< PacketIdBytes > msg, any life_keeper, async_handler_t func)
 
bool connected () const
 Check connection status. More...
 
bool underlying_connected () const
 Check underlying layer connection status. More...
 
void async_read_next_message (any session_life_keeper)
 Trigger next mqtt message manually. If you call this function, you need to set manual receive mode using set_auto_next_read(false);. More...
 
void set_max_queue_send_count (std::size_t count)
 Set maximum number of queued message sending. When async message sending function called during asynchronous processing, the message is enqueued. When current asynchronous message is processed, then concatenate queued messages and send it. This value limits the maximum number of concatenating messages. The default value is 1. More...
 
void set_max_queue_send_size (std::size_t size)
 Set maximum size of queued message sending. When async message sending function called during asynchronous processing, the message is enqueued. When current asynchronous message is processed, then concatenate queued messages and send it. This value limits the maximum size of concatenating messages. The default value is 0. More...
 
protocol_version get_protocol_version () const
 
MQTT_NS::socket const & socket () const
 
MQTT_NS::socketsocket ()
 
auto get_executor ()
 
void set_pingresp_timeout (std::chrono::steady_clock::duration tim)
 Set pingresp timeout. More...
 

Protected Member Functions

 client (as::io_context &ioc, std::string host, std::string port, protocol_version version=protocol_version::v3_1_1, bool async_store_send=false)
 
void on_pre_send () noexcept override
 Pre-send handler This handler is called when any mqtt control packet is decided to send. More...
 
void on_close () noexcept override
 Close handler. More...
 
void on_error (error_code ec) noexcept override
 Error handler. More...
 
 ~client ()=default
 
- Protected Member Functions inherited from MQTT_NS::endpoint< std::mutex, std::lock_guard, 2 >
virtual MQTT_ALWAYS_INLINE void on_mqtt_message_processed (any session_life_keeper)
 next read handler This handler is called when the current mqtt message has been processed. More...
 
std::shared_ptr< MQTT_NS::socket > & socket_sp_ref ()
 Get shared_ptr of socket. More...
 
void async_read_control_packet_type (any session_life_keeper)
 
bool handle_close_or_error (error_code ec)
 
void set_connect ()
 
void set_protocol_version (protocol_version version)
 
void clear_session_data ()
 
 ~endpoint ()=default
 

Friends

std::shared_ptr< callable_overlay< client< tcp_endpoint< as::ip::tcp::socket, as::io_context::strand > > > > make_client (as::io_context &ioc, std::string host, std::string port, protocol_version version)
 Create no tls client with strand. More...
 
std::shared_ptr< callable_overlay< client< tcp_endpoint< as::ip::tcp::socket, null_strand > > > > make_client_no_strand (as::io_context &ioc, std::string host, std::string port, protocol_version version)
 Create no tls client without strand. More...
 
std::shared_ptr< callable_overlay< client< tcp_endpoint< as::ip::tcp::socket, as::io_context::strand >, 4 > > > make_client_32 (as::io_context &ioc, std::string host, std::string port, protocol_version version)
 Create no tls client with strand. More...
 
std::shared_ptr< callable_overlay< client< tcp_endpoint< as::ip::tcp::socket, null_strand >, 4 > > > make_client_no_strand_32 (as::io_context &ioc, std::string host, std::string port, protocol_version version)
 Create no tls client without strand. More...
 

Additional Inherited Members

- Protected Attributes inherited from MQTT_NS::endpoint< std::mutex, std::lock_guard, 2 >
bool clean_start_
 

Member Typedef Documentation

◆ async_handler_t

template<typename Socket , std::size_t PacketIdBytes = 2>
using MQTT_NS::client< Socket, PacketIdBytes >::async_handler_t = typename base::async_handler_t

Constructor & Destructor Documentation

◆ client() [1/2]

template<typename Socket , std::size_t PacketIdBytes = 2>
template<typename ... Args>
MQTT_NS::client< Socket, PacketIdBytes >::client ( constructor_access  ,
Args &&...  args 
)
inline

Constructor used by factory functions at the end of this file.

◆ client() [2/2]

template<typename Socket , std::size_t PacketIdBytes = 2>
MQTT_NS::client< Socket, PacketIdBytes >::client ( as::io_context &  ioc,
std::string  host,
std::string  port,
protocol_version  version = protocol_version::v3_1_1,
bool  async_store_send = false 
)
inlineprotected

◆ ~client()

template<typename Socket , std::size_t PacketIdBytes = 2>
MQTT_NS::client< Socket, PacketIdBytes >::~client ( )
protecteddefault

Member Function Documentation

◆ async_connect() [1/15]

template<typename Socket , std::size_t PacketIdBytes = 2>
void MQTT_NS::client< Socket, PacketIdBytes >::async_connect ( )
inline

Connect to a broker Before calling connect(), call set_xxx member functions to configure the connection.

◆ async_connect() [2/15]

template<typename Socket , std::size_t PacketIdBytes = 2>
void MQTT_NS::client< Socket, PacketIdBytes >::async_connect ( any  session_life_keeper,
async_handler_t  func 
)
inline

Connect to a broker Before calling connect(), call set_xxx member functions to configure the connection.

Parameters
session_life_keeperthe passed object lifetime will be kept during the session.
funcfinish handler that is called when the underlying connection process is finished

◆ async_connect() [3/15]

template<typename Socket , std::size_t PacketIdBytes = 2>
void MQTT_NS::client< Socket, PacketIdBytes >::async_connect ( async_handler_t  func)
inline

Connect to a broker Before calling connect(), call set_xxx member functions to configure the connection.

Parameters
funcfinish handler that is called when the underlying connection process is finished

◆ async_connect() [4/15]

template<typename Socket , std::size_t PacketIdBytes = 2>
void MQTT_NS::client< Socket, PacketIdBytes >::async_connect ( std::shared_ptr< Socket > &&  socket)
inline

Connect to a broker Before calling connect(), call set_xxx member functions to configure the connection.

Parameters
socketThe library uses the socket instead of internal generation. You can configure the socket prior to connect.

◆ async_connect() [5/15]

template<typename Socket , std::size_t PacketIdBytes = 2>
void MQTT_NS::client< Socket, PacketIdBytes >::async_connect ( std::shared_ptr< Socket > &&  socket,
any  session_life_keeper,
async_handler_t  func 
)
inline

Connect to a broker Before calling connect(), call set_xxx member functions to configure the connection.

Parameters
socketThe library uses the socket instead of internal generation. You can configure the socket prior to connect.
session_life_keeperthe passed object lifetime will be kept during the session.
funcfinish handler that is called when the underlying connection process is finished

◆ async_connect() [6/15]

template<typename Socket , std::size_t PacketIdBytes = 2>
void MQTT_NS::client< Socket, PacketIdBytes >::async_connect ( std::shared_ptr< Socket > &&  socket,
async_handler_t  func 
)
inline

Connect to a broker Before calling connect(), call set_xxx member functions to configure the connection.

Parameters
socketThe library uses the socket instead of internal generation. You can configure the socket prior to connect.
funcfinish handler that is called when the underlying connection process is finished

◆ async_connect() [7/15]

template<typename Socket , std::size_t PacketIdBytes = 2>
template<typename T >
std::enable_if_t< !std::is_convertible<T, async_handler_t>::value > MQTT_NS::client< Socket, PacketIdBytes >::async_connect ( std::shared_ptr< Socket > &&  socket,
session_life_keeper 
)
inline

Connect to a broker Before calling connect(), call set_xxx member functions to configure the connection.

Parameters
socketThe library uses the socket instead of internal generation. You can configure the socket prior to connect.
session_life_keeperthe passed object lifetime will be kept during the session.

◆ async_connect() [8/15]

template<typename Socket , std::size_t PacketIdBytes = 2>
void MQTT_NS::client< Socket, PacketIdBytes >::async_connect ( std::shared_ptr< Socket > &&  socket,
v5::properties  props 
)
inline

Connect to a broker Before calling connect(), call set_xxx member functions to configure the connection.

Parameters
socketThe library uses the socket instead of internal generation. You can configure the socket prior to connect.
propsproperties See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901046
3.1.2.11 CONNECT Properties

◆ async_connect() [9/15]

template<typename Socket , std::size_t PacketIdBytes = 2>
void MQTT_NS::client< Socket, PacketIdBytes >::async_connect ( std::shared_ptr< Socket > &&  socket,
v5::properties  props,
any  session_life_keeper,
async_handler_t  func 
)
inline

Connect to a broker Before calling connect(), call set_xxx member functions to configure the connection.

Parameters
socketThe library uses the socket instead of internal generation. You can configure the socket prior to connect.
propsproperties See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901046
3.1.2.11 CONNECT Properties
session_life_keeperthe passed object lifetime will be kept during the session.
funcfinish handler that is called when the underlying connection process is finished

◆ async_connect() [10/15]

template<typename Socket , std::size_t PacketIdBytes = 2>
void MQTT_NS::client< Socket, PacketIdBytes >::async_connect ( std::shared_ptr< Socket > &&  socket,
v5::properties  props,
async_handler_t  func 
)
inline

Connect to a broker Before calling connect(), call set_xxx member functions to configure the connection.

Parameters
socketThe library uses the socket instead of internal generation. You can configure the socket prior to connect.
propsproperties See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901046
3.1.2.11 CONNECT Properties
funcfinish handler that is called when the underlying connection process is finished

◆ async_connect() [11/15]

template<typename Socket , std::size_t PacketIdBytes = 2>
template<typename T >
std::enable_if_t< !std::is_convertible<T, async_handler_t>::value > MQTT_NS::client< Socket, PacketIdBytes >::async_connect ( std::shared_ptr< Socket > &&  socket,
v5::properties  props,
session_life_keeper 
)
inline

Connect to a broker Before calling connect(), call set_xxx member functions to configure the connection.

Parameters
socketThe library uses the socket instead of internal generation. You can configure the socket prior to connect.
propsproperties See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901046
3.1.2.11 CONNECT Properties
session_life_keeperthe passed object lifetime will be kept during the session.

◆ async_connect() [12/15]

template<typename Socket , std::size_t PacketIdBytes = 2>
template<typename T >
std::enable_if_t< !std::is_convertible<T, async_handler_t>::value > MQTT_NS::client< Socket, PacketIdBytes >::async_connect ( session_life_keeper)
inline

Connect to a broker Before calling connect(), call set_xxx member functions to configure the connection.

Parameters
session_life_keeperthe passed object lifetime will be kept during the session.

◆ async_connect() [13/15]

template<typename Socket , std::size_t PacketIdBytes = 2>
void MQTT_NS::client< Socket, PacketIdBytes >::async_connect ( v5::properties  props,
any  session_life_keeper,
async_handler_t  func 
)
inline

Connect to a broker Before calling connect(), call set_xxx member functions to configure the connection.

Parameters
propsproperties See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901046
3.1.2.11 CONNECT Properties
session_life_keeperthe passed object lifetime will be kept during the session.
funcfinish handler that is called when the underlying connection process is finished

◆ async_connect() [14/15]

template<typename Socket , std::size_t PacketIdBytes = 2>
void MQTT_NS::client< Socket, PacketIdBytes >::async_connect ( v5::properties  props,
async_handler_t  func 
)
inline

Connect to a broker Before calling connect(), call set_xxx member functions to configure the connection.

Parameters
propsproperties See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901046
3.1.2.11 CONNECT Properties
funcfinish handler that is called when the underlying connection process is finished

◆ async_connect() [15/15]

template<typename Socket , std::size_t PacketIdBytes = 2>
template<typename T >
std::enable_if_t< !std::is_convertible<T, async_handler_t>::value > MQTT_NS::client< Socket, PacketIdBytes >::async_connect ( v5::properties  props,
session_life_keeper 
)
inline

Connect to a broker Before calling connect(), call set_xxx member functions to configure the connection.

Parameters
propsproperties See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901046
3.1.2.11 CONNECT Properties
session_life_keeperthe passed object lifetime will be kept during the session.

◆ async_disconnect() [1/4]

template<typename Socket , std::size_t PacketIdBytes = 2>
void MQTT_NS::client< Socket, PacketIdBytes >::async_disconnect ( async_handler_t  func = async_handler_t())
inline

Disconnect Send a disconnect packet to the connected broker. It is a clean disconnecting sequence. The broker disconnects the endpoint after receives the disconnect packet.
When the endpoint disconnects using disconnect(), a will won't send.
See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901205

Parameters
funcA callback function that is called when async operation will finish.

◆ async_disconnect() [2/4]

template<typename Socket , std::size_t PacketIdBytes = 2>
void MQTT_NS::client< Socket, PacketIdBytes >::async_disconnect ( std::chrono::steady_clock::duration  timeout,
async_handler_t  func = async_handler_t() 
)
inline

Disconnect Send a disconnect packet to the connected broker. It is a clean disconnecting sequence. The broker disconnects the endpoint after receives the disconnect packet.
When the endpoint disconnects using disconnect(), a will won't send.
See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901205

Parameters
timeoutafter timeout elapsed, force_disconnect() is automatically called.
funcA callback function that is called when async operation will finish.

◆ async_disconnect() [3/4]

template<typename Socket , std::size_t PacketIdBytes = 2>
void MQTT_NS::client< Socket, PacketIdBytes >::async_disconnect ( std::chrono::steady_clock::duration  timeout,
v5::disconnect_reason_code  reason_code,
v5::properties  props,
async_handler_t  func = async_handler_t() 
)
inline

Disconnect Send a disconnect packet to the connected broker. It is a clean disconnecting sequence. The broker disconnects the endpoint after receives the disconnect packet.
When the endpoint disconnects using disconnect(), a will won't send.
See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901205

Parameters
timeoutafter timeout elapsed, force_disconnect() is automatically called.
reason_codeDISCONNECT Reason Code
See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901208
3.14.2.1 Disconnect Reason Code
propsProperties
See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901209
3.14.2.2 DISCONNECT Properties
funcA callback function that is called when async operation will finish.

◆ async_disconnect() [4/4]

template<typename Socket , std::size_t PacketIdBytes = 2>
void MQTT_NS::client< Socket, PacketIdBytes >::async_disconnect ( v5::disconnect_reason_code  reason_code,
v5::properties  props,
async_handler_t  func = async_handler_t() 
)
inline

Disconnect Send a disconnect packet to the connected broker. It is a clean disconnecting sequence. The broker disconnects the endpoint after receives the disconnect packet.
When the endpoint disconnects using disconnect(), a will won't send.
See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901205

Parameters
reason_codeDISCONNECT Reason Code
See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901208
3.14.2.1 Disconnect Reason Code
propsProperties
See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901209
3.14.2.2 DISCONNECT Properties
funcA callback function that is called when async operation will finish.

◆ connect() [1/8]

template<typename Socket , std::size_t PacketIdBytes = 2>
void MQTT_NS::client< Socket, PacketIdBytes >::connect ( any  session_life_keeper = any())
inline

Connect to a broker Before calling connect(), call set_xxx member functions to configure the connection.

Parameters
session_life_keeperthe passed object lifetime will be kept during the session.

◆ connect() [2/8]

template<typename Socket , std::size_t PacketIdBytes = 2>
void MQTT_NS::client< Socket, PacketIdBytes >::connect ( boost::system::error_code &  ec,
any  session_life_keeper = any() 
)
inline

Connect to a broker Before calling connect(), call set_xxx member functions to configure the connection.

Parameters
ecerror code
session_life_keeperthe passed object lifetime will be kept during the session.

◆ connect() [3/8]

template<typename Socket , std::size_t PacketIdBytes = 2>
void MQTT_NS::client< Socket, PacketIdBytes >::connect ( std::shared_ptr< Socket > &&  socket,
any  session_life_keeper = any() 
)
inline

Connect to a broker Before calling connect(), call set_xxx member functions to configure the connection.

Parameters
socketThe library uses the socket instead of internal generation. You can configure the socket prior to connect.
session_life_keeperthe passed object lifetime will be kept during the session.

◆ connect() [4/8]

template<typename Socket , std::size_t PacketIdBytes = 2>
void MQTT_NS::client< Socket, PacketIdBytes >::connect ( std::shared_ptr< Socket > &&  socket,
boost::system::error_code &  ec,
any  session_life_keeper = any() 
)
inline

Connect to a broker Before calling connect(), call set_xxx member functions to configure the connection.

Parameters
socketThe library uses the socket instead of internal generation. You can configure the socket prior to connect.
ecerror code
session_life_keeperthe passed object lifetime will be kept during the session.

◆ connect() [5/8]

template<typename Socket , std::size_t PacketIdBytes = 2>
void MQTT_NS::client< Socket, PacketIdBytes >::connect ( std::shared_ptr< Socket > &&  socket,
v5::properties  props,
any  session_life_keeper = any() 
)
inline

Connect to a broker Before calling connect(), call set_xxx member functions to configure the connection.

Parameters
socketThe library uses the socket instead of internal generation. You can configure the socket prior to connect.
propsproperties See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901046
3.1.2.11 CONNECT Properties
session_life_keeperthe passed object lifetime will be kept during the session.

◆ connect() [6/8]

template<typename Socket , std::size_t PacketIdBytes = 2>
void MQTT_NS::client< Socket, PacketIdBytes >::connect ( std::shared_ptr< Socket > &&  socket,
v5::properties  props,
boost::system::error_code &  ec,
any  session_life_keeper = any() 
)
inline

Connect to a broker Before calling connect(), call set_xxx member functions to configure the connection.

Parameters
socketThe library uses the socket instead of internal generation. You can configure the socket prior to connect.
propsproperties See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901046
3.1.2.11 CONNECT Properties
ecerror code
session_life_keeperthe passed object lifetime will be kept during the session.

◆ connect() [7/8]

template<typename Socket , std::size_t PacketIdBytes = 2>
void MQTT_NS::client< Socket, PacketIdBytes >::connect ( v5::properties  props,
any  session_life_keeper = any() 
)
inline

Connect to a broker Before calling connect(), call set_xxx member functions to configure the connection.

Parameters
propsproperties See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901046
3.1.2.11 CONNECT Properties
session_life_keeperthe passed object lifetime will be kept during the session.

◆ connect() [8/8]

template<typename Socket , std::size_t PacketIdBytes = 2>
void MQTT_NS::client< Socket, PacketIdBytes >::connect ( v5::properties  props,
boost::system::error_code &  ec,
any  session_life_keeper = any() 
)
inline

Connect to a broker Before calling connect(), call set_xxx member functions to configure the connection.

Parameters
propsproperties See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901046
3.1.2.11 CONNECT Properties
ecerror code
session_life_keeperthe passed object lifetime will be kept during the session.

◆ disconnect() [1/2]

template<typename Socket , std::size_t PacketIdBytes = 2>
void MQTT_NS::client< Socket, PacketIdBytes >::disconnect ( std::chrono::steady_clock::duration  timeout,
v5::disconnect_reason_code  reason_code = v5::disconnect_reason_code::normal_disconnection,
v5::properties  props = {} 
)
inline

Disconnect Send a disconnect packet to the connected broker. It is a clean disconnecting sequence. The broker disconnects the endpoint after receives the disconnect packet.
When the endpoint disconnects using disconnect(), a will won't send.
See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901205

Parameters
timeoutafter timeout elapsed, force_disconnect() is automatically called.
reason_codeDISCONNECT Reason Code
See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901208
3.14.2.1 Disconnect Reason Code
propsProperties
See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901209
3.14.2.2 DISCONNECT Properties

◆ disconnect() [2/2]

template<typename Socket , std::size_t PacketIdBytes = 2>
void MQTT_NS::client< Socket, PacketIdBytes >::disconnect ( v5::disconnect_reason_code  reason_code = v5::disconnect_reason_code::normal_disconnection,
v5::properties  props = {} 
)
inline

Disconnect Send a disconnect packet to the connected broker. It is a clean disconnecting sequence. The broker disconnects the endpoint after receives the disconnect packet.
When the endpoint disconnects using disconnect(), a will won't send.
See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901205

Parameters
reason_codeDISCONNECT Reason Code
See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901208
3.14.2.1 Disconnect Reason Code
propsProperties
See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901209
3.14.2.2 DISCONNECT Properties

◆ force_disconnect()

template<typename Socket , std::size_t PacketIdBytes = 2>
void MQTT_NS::client< Socket, PacketIdBytes >::force_disconnect ( )
inline

Disconnect by endpoint Force disconnect. It is not a clean disconnect sequence.
When the endpoint disconnects using force_disconnect(), a will will send.

◆ get_client_id()

template<typename Socket , std::size_t PacketIdBytes = 2>
std::string const& MQTT_NS::client< Socket, PacketIdBytes >::get_client_id ( ) const
inline

Get the client id.

Returns
The client id of this client.

◆ on_close()

template<typename Socket , std::size_t PacketIdBytes = 2>
void MQTT_NS::client< Socket, PacketIdBytes >::on_close ( )
inlineoverrideprotectedvirtualnoexcept

Close handler.

This handler is called if the client called disconnect() and the server closed the socket cleanly. If the socket is closed by other reasons, error_handler is called.

Implements MQTT_NS::endpoint< std::mutex, std::lock_guard, 2 >.

◆ on_error()

template<typename Socket , std::size_t PacketIdBytes = 2>
void MQTT_NS::client< Socket, PacketIdBytes >::on_error ( error_code  ec)
inlineoverrideprotectedvirtualnoexcept

Error handler.

This handler is called if the socket is closed without client's disconnect() call.

Parameters
ecerror code

Implements MQTT_NS::endpoint< std::mutex, std::lock_guard, 2 >.

◆ on_pre_send()

template<typename Socket , std::size_t PacketIdBytes = 2>
void MQTT_NS::client< Socket, PacketIdBytes >::on_pre_send ( )
inlineoverrideprotectedvirtualnoexcept

Pre-send handler This handler is called when any mqtt control packet is decided to send.

Implements MQTT_NS::endpoint< std::mutex, std::lock_guard, 2 >.

◆ set_async_pingreq()

template<typename Socket , std::size_t PacketIdBytes = 2>
void MQTT_NS::client< Socket, PacketIdBytes >::set_async_pingreq ( bool  b)
inline

Set pingreq message sending mode.

Parameters
bIf true then send pingreq asynchronously, otherwise send synchronously.

◆ set_clean_session()

template<typename Socket , std::size_t PacketIdBytes = 2>
void MQTT_NS::client< Socket, PacketIdBytes >::set_clean_session ( bool  cs)
inline

Set clean session.

Parameters
csclean session

This function should be called before calling connect().
See http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc385349231
3.1.2.4 Clean Session
After constructing a endpoint, the clean session is set to false.

◆ set_clean_start()

template<typename Socket , std::size_t PacketIdBytes = 2>
void MQTT_NS::client< Socket, PacketIdBytes >::set_clean_start ( bool  cs)
inline

Set clean start.

Parameters
csclean start

This function should be called before calling connect().
See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901039
3.1.2.4 Clean Start
After constructing a endpoint, the clean start is set to false.

◆ set_client_id()

template<typename Socket , std::size_t PacketIdBytes = 2>
void MQTT_NS::client< Socket, PacketIdBytes >::set_client_id ( std::string  id)
inline

Set client id.

Parameters
idclient id

This function should be called before calling connect().
See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901059
3.1.3.1 Client Identifier

◆ set_host()

template<typename Socket , std::size_t PacketIdBytes = 2>
void MQTT_NS::client< Socket, PacketIdBytes >::set_host ( std::string  host)
inline

Set host.

Parameters
hosthost to connect

The host is used from the next connect() or async_connect() call.

◆ set_keep_alive_sec() [1/2]

template<typename Socket , std::size_t PacketIdBytes = 2>
void MQTT_NS::client< Socket, PacketIdBytes >::set_keep_alive_sec ( std::uint16_t  keep_alive_sec)
inline

Set a keep alive second and a ping milli seconds.

Parameters
keep_alive_seckeep alive seconds

Call set_keep_alive_sec(keep_alive_sec, std::chrono::seconds(keep_alive_sec / 2))
ping_ms is set to a half of keep_alive_sec.
See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc464635115
3.1.2.10 Keep Alive

◆ set_keep_alive_sec() [2/2]

template<typename Socket , std::size_t PacketIdBytes = 2>
void MQTT_NS::client< Socket, PacketIdBytes >::set_keep_alive_sec ( std::uint16_t  keep_alive_sec,
std::chrono::steady_clock::duration  ping 
)
inline

Set a keep alive second and a ping duration.

Parameters
keep_alive_seckeep alive seconds
ping_msping sending interval

When a endpoint connects to a broker, the endpoint notifies keep_alive_sec to the broker. After connecting, the broker starts counting a timeout, and the endpoint starts sending ping packets for each ping_ms. When the broker receives a ping packet, timeout timer is reset. If the broker doesn't receive a ping packet within keep_alive_sec, the endpoint is disconnected.
See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc464635115
3.1.2.10 Keep Alive

◆ set_keep_alive_sec_ping_ms()

template<typename Socket , std::size_t PacketIdBytes = 2>
void MQTT_NS::client< Socket, PacketIdBytes >::set_keep_alive_sec_ping_ms ( std::uint16_t  keep_alive_sec,
std::size_t  ping_ms 
)
inline

Set a keep alive second and a ping milli seconds.

Parameters
keep_alive_seckeep alive seconds
ping_msping sending interval

When a endpoint connects to a broker, the endpoint notifies keep_alive_sec to the broker. After connecting, the broker starts counting a timeout, and the endpoint starts sending ping packets for each ping_ms. When the broker receives a ping packet, timeout timer is reset. If the broker doesn't receive a ping packet within keep_alive_sec, the endpoint is disconnected.
See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc464635115
3.1.2.10 Keep Alive

◆ set_password()

template<typename Socket , std::size_t PacketIdBytes = 2>
void MQTT_NS::client< Socket, PacketIdBytes >::set_password ( std::string  password)
inline

Set password.

Parameters
passwordpassword

This function should be called before calling connect().
See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901072
3.1.3.6 Password

◆ set_port()

template<typename Socket , std::size_t PacketIdBytes = 2>
void MQTT_NS::client< Socket, PacketIdBytes >::set_port ( std::string  port)
inline

Set port.

Parameters
portport tp connect

The port is used from the next connect() or async_connect() call.

◆ set_user_name()

template<typename Socket , std::size_t PacketIdBytes = 2>
void MQTT_NS::client< Socket, PacketIdBytes >::set_user_name ( std::string  name)
inline

Set username.

Parameters
nameusername

This function should be called before calling connect().
See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901071
3.1.3.5 User Name

◆ set_will() [1/2]

template<typename Socket , std::size_t PacketIdBytes = 2>
template<typename ... Args>
void MQTT_NS::client< Socket, PacketIdBytes >::set_will ( Args &&...  args)
inline

◆ set_will() [2/2]

template<typename Socket , std::size_t PacketIdBytes = 2>
void MQTT_NS::client< Socket, PacketIdBytes >::set_will ( will  w)
inline

Set will.

Parameters
wwill

This function should be called before calling connect().
'will' would be send when endpoint is disconnected without calling disconnect().

◆ socket() [1/2]

template<typename Socket , std::size_t PacketIdBytes = 2>
std::shared_ptr<Socket>& MQTT_NS::client< Socket, PacketIdBytes >::socket ( )
inline

◆ socket() [2/2]

template<typename Socket , std::size_t PacketIdBytes = 2>
std::shared_ptr<Socket> const& MQTT_NS::client< Socket, PacketIdBytes >::socket ( ) const
inline

Friends And Related Function Documentation

◆ make_client

template<typename Socket , std::size_t PacketIdBytes = 2>
std::shared_ptr<callable_overlay<client<tcp_endpoint<as::ip::tcp::socket, as::io_context::strand> > > > make_client ( as::io_context &  ioc,
std::string  host,
std::string  port,
protocol_version  version = protocol_version::v3_1_1 
)
friend

Create no tls client with strand.

Parameters
iocio_context object.
hosthostname
portport number
Returns
client object

◆ make_client_32

template<typename Socket , std::size_t PacketIdBytes = 2>
std::shared_ptr<callable_overlay<client<tcp_endpoint<as::ip::tcp::socket, as::io_context::strand>, 4> > > make_client_32 ( as::io_context &  ioc,
std::string  host,
std::string  port,
protocol_version  version = protocol_version::v3_1_1 
)
friend

Create no tls client with strand.

Parameters
iocio_context object.
hosthostname
portport number
Returns
client object

◆ make_client_no_strand

template<typename Socket , std::size_t PacketIdBytes = 2>
std::shared_ptr<callable_overlay<client<tcp_endpoint<as::ip::tcp::socket, null_strand> > > > make_client_no_strand ( as::io_context &  ioc,
std::string  host,
std::string  port,
protocol_version  version = protocol_version::v3_1_1 
)
friend

Create no tls client without strand.

Parameters
iocio_context object.
hosthostname
portport number
Returns
client object

◆ make_client_no_strand_32

template<typename Socket , std::size_t PacketIdBytes = 2>
std::shared_ptr<callable_overlay<client<tcp_endpoint<as::ip::tcp::socket, null_strand>, 4> > > make_client_no_strand_32 ( as::io_context &  ioc,
std::string  host,
std::string  port,
protocol_version  version = protocol_version::v3_1_1 
)
friend

Create no tls client without strand.

Parameters
iocio_context object.
hosthostname
portport number
Returns
client object

The documentation for this class was generated from the following file: