async_mqtt 9.0.1
|
MQTT client for casual usecases. More...
Classes | |
struct | pubres_type |
publish completion handler parameter class More... | |
struct | rebind_executor |
rebinds the client type to another executor More... | |
Public Types | |
using | endpoint_type = basic_endpoint<role::client, 2, NextLayer> |
type of endpoint | |
using | next_layer_type = typename endpoint_type::next_layer_type |
type of the given NextLayer | |
using | lowest_layer_type = typename endpoint_type::lowest_layer_type |
lowest_layer_type of the given NextLayer | |
using | executor_type = typename endpoint_type::executor_type |
executor_type of the given NextLayer | |
Public Member Functions | |
template<typename... Args> | |
client (Args &&... args) | |
constructor | |
client (this_type const &)=delete | |
copy constructor deleted | |
client (this_type &&)=default | |
move constructor | |
~client ()=default | |
destructor This function destroys the client, cancelling any outstanding asynchronous operations associated with the client. | |
this_type & | operator= (this_type const &)=delete |
copy assign operator deleted | |
this_type & | operator= (this_type &&)=default |
move assign operator | |
template<typename... Args> | |
auto | async_start (Args &&... args) |
send CONNECT packet and start packet receive loop | |
template<typename... Args> | |
auto | async_subscribe (Args &&... args) |
send SUBSCRIBE packet | |
template<typename... Args> | |
auto | async_unsubscribe (Args &&... args) |
send UNSUBSCRIBE packet | |
template<typename... Args> | |
auto | async_publish (Args &&... args) |
send PUBLISH packet | |
template<typename... Args> | |
auto | async_disconnect (Args &&... args) |
send DISCONNECT packet | |
template<typename... Args> | |
auto | async_auth (Args &&... args) |
send AUTH packet | |
template<typename CompletionToken = as::default_completion_token_t<executor_type>> | |
async_close (CompletionToken &&token=as::default_completion_token_t< executor_type >{}) | |
close the underlying connection | |
template<typename CompletionToken = as::default_completion_token_t<executor_type>> | |
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 CompletionToken is invoked | |
as::any_io_executor | get_executor () |
executor getter | |
next_layer_type const & | next_layer () const |
next_layer getter | |
next_layer_type & | next_layer () |
next_layer getter | |
lowest_layer_type const & | lowest_layer () const |
lowest_layer getter | |
lowest_layer_type & | lowest_layer () |
lowest_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, then overwrite by LRU algorithm. This function should be called before send() call. | |
void | set_auto_replace_topic_alias_send (bool val) |
auto replace topic with corresponding topic alias on send PUBLISH packet. Registering topic alias need to do manually. This function should be called before send() call. | |
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, then the underlying layer is closed from the client side. If the protocol_version is v5, then send DISCONNECT packet with the reason code disconnect_reason_code::keep_alive_timeout automatically before underlying layer is closed. This function should be called before send() call. | |
void | set_bulk_write (bool val) |
Set bulk write mode. If true, then concatenate multiple packets' const buffer sequence when send() is called before the previous send() is not completed. Otherwise, send packet one by one. This function should be called before send() call. | |
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 internal async_read_some() buffer. Enabling bulk read can improve throughput but may increase latency. Disabling bulk read can reduce latency but may lower throughput. By default, bulk read is disabled. | |
template<typename CompletionToken = as::default_completion_token_t<executor_type>> | |
async_acquire_unique_packet_id (CompletionToken &&token=as::default_completion_token_t< executor_type >{}) | |
acuire unique packet_id. | |
template<typename CompletionToken = as::default_completion_token_t<executor_type>> | |
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. | |
template<typename CompletionToken = as::default_completion_token_t<executor_type>> | |
async_register_packet_id (packet_id_type packet_id, CompletionToken &&token=as::default_completion_token_t< executor_type >{}) | |
register packet_id. | |
template<typename CompletionToken = as::default_completion_token_t<executor_type>> | |
async_release_packet_id (packet_id_type packet_id, CompletionToken &&token=as::default_completion_token_t< executor_type >{}) | |
release packet_id. | |
std::optional< packet_id_type > | acquire_unique_packet_id () |
acuire unique packet_id. | |
bool | register_packet_id (packet_id_type packet_id) |
register packet_id. | |
void | release_packet_id (packet_id_type packet_id) |
release packet_id. | |
MQTT client for casual usecases.
Version | MQTT protocol version. |
NextLayer | Just next layer for basic_endpoint. mqtt, mqtts, ws, and wss are predefined. |
|
explicit |
constructor
Args | Types for the next layer |
args | args for the next layer.
|
std::optional< packet_id_type > async_mqtt::client< Version, NextLayer >::acquire_unique_packet_id | ( | ) |
acuire unique packet_id.
async_mqtt::client< Version, NextLayer >::async_acquire_unique_packet_id | ( | CompletionToken && | token = as::default_completion_token_t< executor_type >{} | ) |
acuire unique packet_id.
token |
|
This asynchronous operation supports cancellation for the following boost::asio::cancellation_type values:
async_mqtt::client< Version, NextLayer >::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.
token |
|
This asynchronous operation supports cancellation for the following boost::asio::cancellation_type values:
auto async_mqtt::client< Version, NextLayer >::async_auth | ( | Args &&... | args | ) |
send AUTH packet
args |
|
This asynchronous operation supports cancellation for the following boost::asio::cancellation_type values:
if they are also supported by the NextLayer type's async_write_some operation.
async_mqtt::client< Version, NextLayer >::async_close | ( | CompletionToken && | token = as::default_completion_token_t< executor_type >{} | ) |
close the underlying connection
token | the param is void |
This asynchronous operation supports cancellation for the following boost::asio::cancellation_type values:
auto async_mqtt::client< Version, NextLayer >::async_disconnect | ( | Args &&... | args | ) |
send DISCONNECT packet
args |
|
This asynchronous operation supports cancellation for the following boost::asio::cancellation_type values:
if they are also supported by the NextLayer type's async_write_some operation.
auto async_mqtt::client< Version, NextLayer >::async_publish | ( | Args &&... | args | ) |
send PUBLISH packet
args |
|
This asynchronous operation supports cancellation for the following boost::asio::cancellation_type values:
if they are also supported by the NextLayer type's async_read_some and async_write_some operation.
async_mqtt::client< Version, NextLayer >::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 CompletionToken is invoked
token | the params are
|
if they are also supported by the NextLayer type's async_read_some operation.
async_mqtt::client< Version, NextLayer >::async_register_packet_id | ( | packet_id_type | packet_id, |
CompletionToken && | token = as::default_completion_token_t< executor_type >{} ) |
register packet_id.
packet_id | packet_id to register |
token |
|
This asynchronous operation supports cancellation for the following boost::asio::cancellation_type values:
async_mqtt::client< Version, NextLayer >::async_release_packet_id | ( | packet_id_type | packet_id, |
CompletionToken && | token = as::default_completion_token_t< executor_type >{} ) |
release packet_id.
packet_id | packet_id to release |
token |
|
This asynchronous operation supports cancellation for the following boost::asio::cancellation_type values:
auto async_mqtt::client< Version, NextLayer >::async_start | ( | Args &&... | args | ) |
send CONNECT packet and start packet receive loop
args |
|
This asynchronous operation supports cancellation for the following boost::asio::cancellation_type values:
if they are also supported by the NextLayer type's async_read_some and async_write_some operation.
auto async_mqtt::client< Version, NextLayer >::async_subscribe | ( | Args &&... | args | ) |
send SUBSCRIBE packet
args |
|
This asynchronous operation supports cancellation for the following boost::asio::cancellation_type values:
if they are also supported by the NextLayer type's async_read_some and async_write_some operation.
auto async_mqtt::client< Version, NextLayer >::async_unsubscribe | ( | Args &&... | args | ) |
send UNSUBSCRIBE packet
args |
|
This asynchronous operation supports cancellation for the following boost::asio::cancellation_type values:
if they are also supported by the NextLayer type's async_read_some and async_write_some operation.
endpoint_type & async_mqtt::client< Version, NextLayer >::get_endpoint | ( | ) |
get endpoint This is for detail operation
endpoint_type const & async_mqtt::client< Version, NextLayer >::get_endpoint | ( | ) | const |
get endpoint This is for detail operation
as::any_io_executor async_mqtt::client< Version, NextLayer >::get_executor | ( | ) |
executor getter
lowest_layer_type & async_mqtt::client< Version, NextLayer >::lowest_layer | ( | ) |
lowest_layer getter
lowest_layer_type const & async_mqtt::client< Version, NextLayer >::lowest_layer | ( | ) | const |
lowest_layer getter
next_layer_type & async_mqtt::client< Version, NextLayer >::next_layer | ( | ) |
next_layer getter
next_layer_type const & async_mqtt::client< Version, NextLayer >::next_layer | ( | ) | const |
next_layer getter
bool async_mqtt::client< Version, NextLayer >::register_packet_id | ( | packet_id_type | packet_id | ) |
register packet_id.
packet_id | packet_id to register |
void async_mqtt::client< Version, NextLayer >::release_packet_id | ( | packet_id_type | packet_id | ) |
release packet_id.
packet_id | packet_id to release |
void async_mqtt::client< Version, NextLayer >::set_auto_map_topic_alias_send | ( | bool | val | ) |
auto map (allocate) topic alias on send PUBLISH packet. If all topic aliases are used, then overwrite by LRU algorithm.
This function should be called before send() call.
val | if true, enable auto mapping, otherwise disable. |
void async_mqtt::client< Version, NextLayer >::set_auto_replace_topic_alias_send | ( | bool | val | ) |
auto replace topic with corresponding topic alias on send PUBLISH packet. Registering topic alias need to do manually.
This function should be called before send() call.
val | if true, enable auto replacing, otherwise disable. |
void async_mqtt::client< Version, NextLayer >::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 internal async_read_some()
buffer. Enabling bulk read can improve throughput but may increase latency. Disabling bulk read can reduce latency but may lower throughput. By default, bulk read is disabled.
val | If set to 0, bulk read is disabled. Otherwise, it specifies the buffer size. |
void async_mqtt::client< Version, NextLayer >::set_bulk_write | ( | bool | val | ) |
Set bulk write mode. If true, then concatenate multiple packets' const buffer sequence when send() is called before the previous send() is not completed. Otherwise, send packet one by one.
This function should be called before send() call.
val | if true, enable bulk write mode, otherwise disable it. |
void async_mqtt::client< Version, NextLayer >::set_pingresp_recv_timeout | ( | std::chrono::milliseconds | duration | ) |
Set timeout for receiving PINGRESP packet after PINGREQ packet is sent. If the timer is fired, then the underlying layer is closed from the client side. If the protocol_version is v5, then send DISCONNECT packet with the reason code disconnect_reason_code::keep_alive_timeout automatically before underlying layer is closed.
This function should be called before send() call.
duration | if zero, timer is not set; otherwise duration is set. The minimum resolution is in milliseconds. |