7#if !defined(ASYNC_MQTT_CLIENT_HPP)
8#define ASYNC_MQTT_CLIENT_HPP
10#include <async_mqtt/detail/client_impl.hpp>
19namespace as = boost::asio;
21template <protocol_version Version,
typename NextLayer>
24 using impl_type = detail::client_impl<Version, NextLayer>;
39 ASYNC_MQTT_PACKET_TYPE(Version,
connect)
40 ASYNC_MQTT_PACKET_TYPE(Version,
connack)
41 ASYNC_MQTT_PACKET_TYPE(Version,
subscribe)
42 ASYNC_MQTT_PACKET_TYPE(Version,
suback)
44 ASYNC_MQTT_PACKET_TYPE(Version,
unsuback)
45 ASYNC_MQTT_PACKET_TYPE(Version,
publish)
46 ASYNC_MQTT_PACKET_TYPE(Version,
puback)
47 ASYNC_MQTT_PACKET_TYPE(Version,
pubrec)
48 ASYNC_MQTT_PACKET_TYPE(Version,
pubrel)
49 ASYNC_MQTT_PACKET_TYPE(Version,
pubcomp)
50 ASYNC_MQTT_PACKET_TYPE(Version,
pingreq)
51 ASYNC_MQTT_PACKET_TYPE(Version,
pingresp)
82 template <
typename... Args>
159 template <
typename... Args>
206 template <
typename... Args>
253 template <
typename... Args>
302 template <
typename... Args>
333 template <
typename... Args>
363 template <
typename... Args>
378 typename CompletionToken = as::default_completion_token_t<executor_type>
380#if !defined(GENERATING_DOCUMENTATION)
381 BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(
387 CompletionToken&& token = as::default_completion_token_t<executor_type>{}
412 typename CompletionToken = as::default_completion_token_t<executor_type>
414#if !defined(GENERATING_DOCUMENTATION)
415 BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(
421 CompletionToken&& token = as::default_completion_token_t<executor_type>{}
537 typename CompletionToken = as::default_completion_token_t<executor_type>
539#if !defined(GENERATING_DOCUMENTATION)
540 BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(
546 CompletionToken&& token = as::default_completion_token_t<executor_type>{}
566 typename CompletionToken = as::default_completion_token_t<executor_type>
568#if !defined(GENERATING_DOCUMENTATION)
569 BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(
575 CompletionToken&& token = as::default_completion_token_t<executor_type>{}
596 typename CompletionToken = as::default_completion_token_t<executor_type>
598#if !defined(GENERATING_DOCUMENTATION)
599 BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(
606 CompletionToken&& token = as::default_completion_token_t<executor_type>{}
626 typename CompletionToken = as::default_completion_token_t<executor_type>
628#if !defined(GENERATING_DOCUMENTATION)
629 BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(
636 CompletionToken&& token = as::default_completion_token_t<executor_type>{}
661 template <
typename Executor1>
675 template <
typename Other>
682 typename CompletionToken = as::default_completion_token_t<executor_type>
684#if !defined(GENERATING_DOCUMENTATION)
685 BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(
687 void(
error_code, std::optional<connack_packet>)
692 std::optional<connect_packet> packet,
693 CompletionToken&& token = as::default_completion_token_t<executor_type>{}
697 typename CompletionToken = as::default_completion_token_t<executor_type>
699#if !defined(GENERATING_DOCUMENTATION)
700 BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(
702 void(
error_code, std::optional<suback_packet>)
705 async_subscribe_impl(
707 std::optional<subscribe_packet> packet,
708 CompletionToken&& token = as::default_completion_token_t<executor_type>{}
712 typename CompletionToken = as::default_completion_token_t<executor_type>
714#if !defined(GENERATING_DOCUMENTATION)
715 BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(
717 void(
error_code, std::optional<suback_packet>)
720 async_unsubscribe_impl(
722 std::optional<unsubscribe_packet> packet,
723 CompletionToken&& token = as::default_completion_token_t<executor_type>{}
727 typename CompletionToken = as::default_completion_token_t<executor_type>
729#if !defined(GENERATING_DOCUMENTATION)
730 BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(
737 std::optional<publish_packet> packet,
738 CompletionToken&& token = as::default_completion_token_t<executor_type>{}
742 typename CompletionToken = as::default_completion_token_t<executor_type>
744#if !defined(GENERATING_DOCUMENTATION)
745 BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(
750 async_disconnect_impl(
752 std::optional<disconnect_packet> packet,
753 CompletionToken&& token = as::default_completion_token_t<executor_type>{}
757 typename CompletionToken = as::default_completion_token_t<executor_type>
759#if !defined(GENERATING_DOCUMENTATION)
760 BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(
767 std::optional<v5::auth_packet> packet,
768 CompletionToken&& token = as::default_completion_token_t<executor_type>{}
774 std::shared_ptr<impl_type> impl_;
779#include <async_mqtt/impl/client_impl.hpp>
780#include <async_mqtt/impl/client_start.hpp>
781#include <async_mqtt/impl/client_subscribe.hpp>
782#include <async_mqtt/impl/client_unsubscribe.hpp>
783#include <async_mqtt/impl/client_publish.hpp>
784#include <async_mqtt/impl/client_disconnect.hpp>
785#include <async_mqtt/impl/client_auth.hpp>
786#include <async_mqtt/impl/client_close.hpp>
787#include <async_mqtt/impl/client_recv.hpp>
788#include <async_mqtt/impl/client_acquire_unique_packet_id.hpp>
789#include <async_mqtt/impl/client_acquire_unique_packet_id_wait_until.hpp>
790#include <async_mqtt/impl/client_register_packet_id.hpp>
791#include <async_mqtt/impl/client_release_packet_id.hpp>
MQTT endpoint corresponding to the connection.
Definition endpoint_fwd.hpp:32
typename next_layer_type::executor_type executor_type
executor_type of the given NextLayer
Definition endpoint.hpp:48
typename stream_type::lowest_layer_type lowest_layer_type
lowest_layer_type of the given NextLayer
Definition endpoint.hpp:45
typename stream_type::next_layer_type next_layer_type
type of the given NextLayer
Definition endpoint.hpp:42
MQTT client for casual usecases.
Definition client_fwd.hpp:82
void set_pingresp_recv_timeout(std::chrono::milliseconds duration)
Set timeout for receiving PINGRESP packet after PINGREQ packet is sent. If the timer is fired,...
client(this_type const &)=delete
copy constructor deleted
void set_auto_replace_topic_alias_send(bool val)
auto replace topic with corresponding topic alias on send PUBLISH packet. Registering topic alias nee...
as::any_io_executor get_executor()
executor getter
async_acquire_unique_packet_id_wait_until(CompletionToken &&token=as::default_completion_token_t< executor_type >{})
acuire unique packet_id. If packet_id is fully acquired, then wait until released.
auto async_subscribe(Args &&... args)
send SUBSCRIBE packet
next_layer_type const & next_layer() const
next_layer getter
async_release_packet_id(packet_id_type packet_id, CompletionToken &&token=as::default_completion_token_t< executor_type >{})
release packet_id.
auto async_unsubscribe(Args &&... args)
send UNSUBSCRIBE packet
bool register_packet_id(packet_id_type packet_id)
register packet_id.
next_layer_type & next_layer()
next_layer getter
endpoint_type const & get_endpoint() const
get endpoint This is for detail operation
endpoint_type & get_endpoint()
get endpoint This is for detail operation
void set_auto_map_topic_alias_send(bool val)
auto map (allocate) topic alias on send PUBLISH packet. If all topic aliases are used,...
lowest_layer_type & lowest_layer()
lowest_layer getter
void release_packet_id(packet_id_type packet_id)
release packet_id.
auto async_start(Args &&... args)
send CONNECT packet and start packet receive loop
typename endpoint_type::next_layer_type next_layer_type
type of the given NextLayer
Definition client.hpp:31
async_recv(CompletionToken &&token=as::default_completion_token_t< executor_type >{})
receive PUBLISH or DISCONNECT packet users CANNOT call recv() before the previous recv()'s Completion...
lowest_layer_type const & lowest_layer() const
lowest_layer getter
typename endpoint_type::executor_type executor_type
executor_type of the given NextLayer
Definition client.hpp:37
auto async_auth(Args &&... args)
send AUTH packet
client(Args &&... args)
constructor
async_close(CompletionToken &&token=as::default_completion_token_t< executor_type >{})
close the underlying connection
void set_bulk_write(bool val)
Set bulk write mode. If true, then concatenate multiple packets' const buffer sequence when send() is...
this_type & operator=(this_type &&)=default
move assign operator
std::optional< packet_id_type > acquire_unique_packet_id()
acuire unique packet_id.
client(this_type &&)=default
move constructor
~client()=default
destructor This function destroys the client, cancelling any outstanding asynchronous operations asso...
async_register_packet_id(packet_id_type packet_id, CompletionToken &&token=as::default_completion_token_t< executor_type >{})
register packet_id.
auto async_disconnect(Args &&... args)
send DISCONNECT packet
async_acquire_unique_packet_id(CompletionToken &&token=as::default_completion_token_t< executor_type >{})
acuire unique packet_id.
auto async_publish(Args &&... args)
send PUBLISH packet
typename endpoint_type::lowest_layer_type lowest_layer_type
lowest_layer_type of the given NextLayer
Definition client.hpp:34
void set_bulk_read_buffer_size(std::size_t val)
Set the bulk read buffer size. If bulk read is enabled, the val parameter specifies the size of the i...
this_type & operator=(this_type const &)=delete
copy assign operator deleted
sys::error_code error_code
sys is a namespace alias of boost::sytem.
Definition error.hpp:56
typename basic_packet_id_type< 2 >::type packet_id_type
packet idenfitifer type
Definition packet_id_type.hpp:46
@ disconnect
DISCONNECT(14)
@ unsubscribe
UNSUBSCRIBE(10)
@ client
as client. Can't send CONNACK, SUBACK, UNSUBACK, PINGRESP. Can send Other packets.
publish completion handler parameter class
Definition client.hpp:57
std::optional< pubrec_packet > pubrec_opt
Definition client.hpp:65
std::optional< pubcomp_packet > pubcomp_opt
Definition client.hpp:69
std::optional< puback_packet > puback_opt
Definition client.hpp:61
rebinds the client type to another executor
Definition client.hpp:662