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

#include <sync_client.hpp>

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

Public Member Functions

template<typename ... Args>
 sync_client (constructor_access, Args &&... args)
 
void set_auto_pub_response (bool b=true)
 Set auto publish response mode. More...
 
void async_connect ()=delete
 
void async_disconnect ()=delete
 
void async_publish ()=delete
 
void async_subscribe ()=delete
 
void async_unsubscribe ()=delete
 
void async_pingresp ()=delete
 
void async_connack ()=delete
 
void async_puback ()=delete
 
void async_pubrec ()=delete
 
void async_pubrel ()=delete
 
void async_pubcomp ()=delete
 
void async_suback ()=delete
 
void async_unsuback ()=delete
 
- Public Member Functions inherited from MQTT_NS::client< Socket, 2 >
 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...
 
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 (std::uint16_t keep_alive_sec)
 Set a keep alive second and a ping milli seconds. 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 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...
 
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...
 
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...
 
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...
 
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, PacketIdBytes >
 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

 ~sync_client ()=default
 
 sync_client (as::io_context &ioc, std::string host, std::string port, protocol_version version=protocol_version::v3_1_1)
 
- Protected Member Functions inherited from MQTT_NS::client< Socket, 2 >
 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, PacketIdBytes >
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< sync_client< tcp_endpoint< as::ip::tcp::socket, as::io_context::strand > > > > make_sync_client (as::io_context &ioc, std::string host, std::string port, protocol_version version)
 Create no tls sync_client with strand. More...
 
std::shared_ptr< callable_overlay< sync_client< tcp_endpoint< as::ip::tcp::socket, null_strand > > > > make_sync_client_no_strand (as::io_context &ioc, std::string host, std::string port, protocol_version version)
 Create no tls sync_client without strand. More...
 
std::shared_ptr< callable_overlay< sync_client< tcp_endpoint< as::ip::tcp::socket, as::io_context::strand >, 4 > > > make_sync_client_32 (as::io_context &ioc, std::string host, std::string port, protocol_version version)
 Create no tls sync_client with strand. More...
 
std::shared_ptr< callable_overlay< sync_client< tcp_endpoint< as::ip::tcp::socket, null_strand >, 4 > > > make_sync_client_no_strand_32 (as::io_context &ioc, std::string host, std::string port, protocol_version version)
 Create no tls sync_client without strand. More...
 

Additional Inherited Members

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

Constructor & Destructor Documentation

◆ sync_client() [1/2]

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

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

◆ ~sync_client()

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

◆ sync_client() [2/2]

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

Member Function Documentation

◆ async_connack()

template<typename Socket , std::size_t PacketIdBytes = 2>
void MQTT_NS::sync_client< Socket, PacketIdBytes >::async_connack ( )
delete

◆ async_connect()

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

◆ async_disconnect()

template<typename Socket , std::size_t PacketIdBytes = 2>
void MQTT_NS::sync_client< Socket, PacketIdBytes >::async_disconnect ( )
delete

◆ async_pingresp()

template<typename Socket , std::size_t PacketIdBytes = 2>
void MQTT_NS::sync_client< Socket, PacketIdBytes >::async_pingresp ( )
delete

◆ async_puback()

template<typename Socket , std::size_t PacketIdBytes = 2>
void MQTT_NS::sync_client< Socket, PacketIdBytes >::async_puback ( )
delete

◆ async_pubcomp()

template<typename Socket , std::size_t PacketIdBytes = 2>
void MQTT_NS::sync_client< Socket, PacketIdBytes >::async_pubcomp ( )
delete

◆ async_publish()

template<typename Socket , std::size_t PacketIdBytes = 2>
void MQTT_NS::sync_client< Socket, PacketIdBytes >::async_publish ( )
delete

◆ async_pubrec()

template<typename Socket , std::size_t PacketIdBytes = 2>
void MQTT_NS::sync_client< Socket, PacketIdBytes >::async_pubrec ( )
delete

◆ async_pubrel()

template<typename Socket , std::size_t PacketIdBytes = 2>
void MQTT_NS::sync_client< Socket, PacketIdBytes >::async_pubrel ( )
delete

◆ async_suback()

template<typename Socket , std::size_t PacketIdBytes = 2>
void MQTT_NS::sync_client< Socket, PacketIdBytes >::async_suback ( )
delete

◆ async_subscribe()

template<typename Socket , std::size_t PacketIdBytes = 2>
void MQTT_NS::sync_client< Socket, PacketIdBytes >::async_subscribe ( )
delete

◆ async_unsuback()

template<typename Socket , std::size_t PacketIdBytes = 2>
void MQTT_NS::sync_client< Socket, PacketIdBytes >::async_unsuback ( )
delete

◆ async_unsubscribe()

template<typename Socket , std::size_t PacketIdBytes = 2>
void MQTT_NS::sync_client< Socket, PacketIdBytes >::async_unsubscribe ( )
delete

◆ set_auto_pub_response()

template<typename Socket , std::size_t PacketIdBytes = 2>
void MQTT_NS::sync_client< Socket, PacketIdBytes >::set_auto_pub_response ( bool  b = true)
inline

Set auto publish response mode.

Parameters
bset value
syncauto publish ressponse send synchronous

When set auto publish response mode to true, puback, pubrec, pubrel,and pub comp automatically send.

Friends And Related Function Documentation

◆ make_sync_client

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

Create no tls sync_client with strand.

Parameters
iocio_context object.
hosthostname
portport number
Returns
sync_client object

◆ make_sync_client_32

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

Create no tls sync_client with strand.

Parameters
iocio_context object.
hosthostname
portport number
Returns
sync_client object

◆ make_sync_client_no_strand

template<typename Socket , std::size_t PacketIdBytes = 2>
std::shared_ptr<callable_overlay<sync_client<tcp_endpoint<as::ip::tcp::socket, null_strand> > > > make_sync_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 sync_client without strand.

Parameters
iocio_context object.
hosthostname
portport number
Returns
sync_client object

◆ make_sync_client_no_strand_32

template<typename Socket , std::size_t PacketIdBytes = 2>
std::shared_ptr<callable_overlay<sync_client<tcp_endpoint<as::ip::tcp::socket, null_strand>, 4> > > make_sync_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 sync_client without strand.

Parameters
iocio_context object.
hosthostname
portport number
Returns
sync_client object

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