async_mqtt 9.0.1
|
MQTT endpoint corresponding to the connection. More...
Classes | |
struct | rebind_executor |
rebinds the basic_endpoint type to another executor More... | |
Public Types | |
using | next_layer_type = typename stream_type::next_layer_type |
type of the given NextLayer | |
using | lowest_layer_type = typename stream_type::lowest_layer_type |
lowest_layer_type of the given NextLayer | |
using | executor_type = typename next_layer_type::executor_type |
executor_type of the given NextLayer | |
using | packet_variant_type = basic_packet_variant<PacketIdBytes> |
Type of packet_variant. | |
Public Member Functions | |
template<typename... Args> | |
basic_endpoint (protocol_version ver, Args &&... args) | |
constructor | |
~basic_endpoint () | |
destructor This function destroys the basic_endpoint, cancelling any outstanding asynchronous operations associated with the basic_endpoint. | |
basic_endpoint (this_type const &)=delete | |
copy constructor deleted | |
basic_endpoint (this_type &&)=default | |
move constructor | |
this_type & | operator= (this_type const &)=delete |
copy assign operator deleted | |
this_type & | operator= (this_type &&)=default |
move assign operator | |
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 | |
void | set_auto_pub_response (bool val) |
auto publish response setter. Should be called before send()/recv() call. | |
void | set_auto_ping_response (bool val) |
auto pingreq response setter. Should be called before send()/recv() call. | |
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 (typename basic_packet_id_type< PacketIdBytes >::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 (typename basic_packet_id_type< PacketIdBytes >::type packet_id, CompletionToken &&token=as::default_completion_token_t< executor_type >{}) | |
release packet_id. | |
template<typename Packet , typename CompletionToken = as::default_completion_token_t<executor_type>> | |
async_send (Packet packet, CompletionToken &&token=as::default_completion_token_t< executor_type >{}) | |
send packet users can call send() before the previous send()'s CompletionToken is invoked | |
template<typename CompletionToken = as::default_completion_token_t<executor_type>> | |
async_recv (CompletionToken &&token=as::default_completion_token_t< executor_type >{}) | |
receive packet | |
template<typename CompletionToken = as::default_completion_token_t<executor_type>> | |
async_recv (std::set< control_packet_type > types, CompletionToken &&token=as::default_completion_token_t< executor_type >{}) | |
receive packet if packet is not filterd, then next recv() starts automatically. if receive error happenes, then token would be invoked. | |
template<typename CompletionToken = as::default_completion_token_t<executor_type>> | |
async_recv (filter fil, std::set< control_packet_type > types, CompletionToken &&token=as::default_completion_token_t< executor_type >{}) | |
receive packet if packet is not filterd, then next recv() starts automatically. if receive error happenes, then token would be invoked. | |
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_restore_packets (std::vector< basic_store_packet_variant< PacketIdBytes > > pvs, CompletionToken &&token=as::default_completion_token_t< executor_type >{}) | |
restore packets the restored packets would automatically send when CONNACK packet is received | |
template<typename CompletionToken = as::default_completion_token_t<executor_type>> | |
async_get_stored_packets (CompletionToken &&token=as::default_completion_token_t< executor_type >{}) | |
get stored packets | |
template<typename CompletionToken = as::default_completion_token_t<executor_type>> | |
async_regulate_for_store (v5::basic_publish_packet< PacketIdBytes > packet, CompletionToken &&token=as::default_completion_token_t< executor_type >{}) | |
regulate publish packet for store remove topic alias from the packet and extract the topic name | |
std::optional< typename basic_packet_id_type< PacketIdBytes >::type > | acquire_unique_packet_id () |
acuire unique packet_id. | |
bool | register_packet_id (typename basic_packet_id_type< PacketIdBytes >::type packet_id) |
register packet_id. | |
void | release_packet_id (typename basic_packet_id_type< PacketIdBytes >::type packet_id) |
release packet_id. | |
std::set< typename basic_packet_id_type< PacketIdBytes >::type > | get_qos2_publish_handled_pids () const |
Get processed but not released QoS2 packet ids This function should be called after disconnection. | |
void | restore_qos2_publish_handled_pids (std::set< typename basic_packet_id_type< PacketIdBytes >::type > pids) |
Restore processed but not released QoS2 packet ids This function should be called before receive the first publish. | |
void | restore_packets (std::vector< basic_store_packet_variant< PacketIdBytes > > pvs) |
restore packets the restored packets would automatically send when CONNACK packet is received | |
std::vector< basic_store_packet_variant< PacketIdBytes > > | get_stored_packets () const |
get stored packets sotred packets mean inflight packets. | |
protocol_version | get_protocol_version () const |
get MQTT protocol version | |
bool | is_publish_processing (typename basic_packet_id_type< PacketIdBytes >::type pid) const |
Get MQTT PUBLISH packet processing status. | |
void | regulate_for_store (v5::basic_publish_packet< PacketIdBytes > &packet, error_code &ec) const |
Regulate publish packet for store If topic is empty, extract topic from topic alias, and remove topic alias Otherwise, remove topic alias if exists. | |
void | set_pingreq_send_interval (std::chrono::milliseconds duration) |
Set PINGREQ packet sending interval. | |
Related Symbols | |
(Note that these are not member symbols.) | |
template<role Role, typename NextLayer > | |
using | endpoint = basic_endpoint<Role, 2, NextLayer> |
Type alias of basic_endpoint (PacketIdBytes=2). This is for typical usecase. | |
MQTT endpoint corresponding to the connection.
Role | role for packet sendable checking |
PacketIdBytes | MQTT spec is 2. You can use endpoint for that. |
NextLayer | Just next layer for basic_endpoint. mqtt, mqtts, ws, and wss are predefined. |
|
explicit |
constructor
Args | Types for the next layer |
ver | MQTT protocol version client can set v5 or v3_1_1, in addition server can set undetermined |
args | args for the next layer.
|
std::optional< typename basic_packet_id_type< PacketIdBytes >::type > async_mqtt::basic_endpoint< Role, PacketIdBytes, NextLayer >::acquire_unique_packet_id | ( | ) |
acuire unique packet_id.
async_mqtt::basic_endpoint< Role, PacketIdBytes, 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::basic_endpoint< Role, PacketIdBytes, 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:
async_mqtt::basic_endpoint< Role, PacketIdBytes, NextLayer >::async_close | ( | CompletionToken && | token = as::default_completion_token_t< executor_type >{} | ) |
close the underlying connection
token |
|
This asynchronous operation supports cancellation for the following boost::asio::cancellation_type values:
async_mqtt::basic_endpoint< Role, PacketIdBytes, NextLayer >::async_get_stored_packets | ( | CompletionToken && | token = as::default_completion_token_t< executor_type >{} | ) |
get stored packets
token |
|
This asynchronous operation supports cancellation for the following boost::asio::cancellation_type values:
async_mqtt::basic_endpoint< Role, PacketIdBytes, NextLayer >::async_recv | ( | CompletionToken && | token = as::default_completion_token_t< executor_type >{} | ) |
receive packet
token |
|
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 operation.
async_mqtt::basic_endpoint< Role, PacketIdBytes, NextLayer >::async_recv | ( | filter | fil, |
std::set< control_packet_type > | types, | ||
CompletionToken && | token = as::default_completion_token_t< executor_type >{} ) |
receive packet if packet is not filterd, then next recv() starts automatically. if receive error happenes, then token would be invoked.
fil | if match then matched types are targets. if except then not matched types are targets. |
types | target control_packet_types |
token |
|
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 operation.
async_mqtt::basic_endpoint< Role, PacketIdBytes, NextLayer >::async_recv | ( | std::set< control_packet_type > | types, |
CompletionToken && | token = as::default_completion_token_t< executor_type >{} ) |
receive packet if packet is not filterd, then next recv() starts automatically. if receive error happenes, then token would be invoked.
types | target control_packet_types |
token |
|
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 operation.
async_mqtt::basic_endpoint< Role, PacketIdBytes, NextLayer >::async_register_packet_id | ( | typename basic_packet_id_type< PacketIdBytes >::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::basic_endpoint< Role, PacketIdBytes, NextLayer >::async_regulate_for_store | ( | v5::basic_publish_packet< PacketIdBytes > | packet, |
CompletionToken && | token = as::default_completion_token_t< executor_type >{} ) |
regulate publish packet for store remove topic alias from the packet and extract the topic name
packet | target packet to regulate |
token |
|
This asynchronous operation supports cancellation for the following boost::asio::cancellation_type values:
async_mqtt::basic_endpoint< Role, PacketIdBytes, NextLayer >::async_release_packet_id | ( | typename basic_packet_id_type< PacketIdBytes >::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:
async_mqtt::basic_endpoint< Role, PacketIdBytes, NextLayer >::async_restore_packets | ( | std::vector< basic_store_packet_variant< PacketIdBytes > > | pvs, |
CompletionToken && | token = as::default_completion_token_t< executor_type >{} ) |
restore packets the restored packets would automatically send when CONNACK packet is received
pvs | packets to restore |
token |
|
This asynchronous operation supports cancellation for the following boost::asio::cancellation_type values:
async_mqtt::basic_endpoint< Role, PacketIdBytes, NextLayer >::async_send | ( | Packet | packet, |
CompletionToken && | token = as::default_completion_token_t< executor_type >{} ) |
send packet users can call send() before the previous send()'s CompletionToken is invoked
packet | packet to send |
token |
|
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.
as::any_io_executor async_mqtt::basic_endpoint< Role, PacketIdBytes, NextLayer >::get_executor | ( | ) |
executor getter
protocol_version async_mqtt::basic_endpoint< Role, PacketIdBytes, NextLayer >::get_protocol_version | ( | ) | const |
get MQTT protocol version
std::set< typename basic_packet_id_type< PacketIdBytes >::type > async_mqtt::basic_endpoint< Role, PacketIdBytes, NextLayer >::get_qos2_publish_handled_pids | ( | ) | const |
Get processed but not released QoS2 packet ids This function should be called after disconnection.
std::vector< basic_store_packet_variant< PacketIdBytes > > async_mqtt::basic_endpoint< Role, PacketIdBytes, NextLayer >::get_stored_packets | ( | ) | const |
get stored packets sotred packets mean inflight packets.
bool async_mqtt::basic_endpoint< Role, PacketIdBytes, NextLayer >::is_publish_processing | ( | typename basic_packet_id_type< PacketIdBytes >::type | pid | ) | const |
Get MQTT PUBLISH packet processing status.
pid | packet_id corresponding to the publish packet. |
lowest_layer_type & async_mqtt::basic_endpoint< Role, PacketIdBytes, NextLayer >::lowest_layer | ( | ) |
lowest_layer getter
lowest_layer_type const & async_mqtt::basic_endpoint< Role, PacketIdBytes, NextLayer >::lowest_layer | ( | ) | const |
lowest_layer getter
next_layer_type & async_mqtt::basic_endpoint< Role, PacketIdBytes, NextLayer >::next_layer | ( | ) |
next_layer getter
next_layer_type const & async_mqtt::basic_endpoint< Role, PacketIdBytes, NextLayer >::next_layer | ( | ) | const |
next_layer getter
bool async_mqtt::basic_endpoint< Role, PacketIdBytes, NextLayer >::register_packet_id | ( | typename basic_packet_id_type< PacketIdBytes >::type | packet_id | ) |
register packet_id.
packet_id | packet_id to register |
void async_mqtt::basic_endpoint< Role, PacketIdBytes, NextLayer >::regulate_for_store | ( | v5::basic_publish_packet< PacketIdBytes > & | packet, |
error_code & | ec ) const |
Regulate publish packet for store If topic is empty, extract topic from topic alias, and remove topic alias Otherwise, remove topic alias if exists.
packet | packet to regulate |
ec | error_code for repoting error |
void async_mqtt::basic_endpoint< Role, PacketIdBytes, NextLayer >::release_packet_id | ( | typename basic_packet_id_type< PacketIdBytes >::type | packet_id | ) |
release packet_id.
packet_id | packet_id to release |
void async_mqtt::basic_endpoint< Role, PacketIdBytes, NextLayer >::restore_packets | ( | std::vector< basic_store_packet_variant< PacketIdBytes > > | pvs | ) |
restore packets the restored packets would automatically send when CONNACK packet is received
pvs | packets to restore |
void async_mqtt::basic_endpoint< Role, PacketIdBytes, NextLayer >::restore_qos2_publish_handled_pids | ( | std::set< typename basic_packet_id_type< PacketIdBytes >::type > | pids | ) |
Restore processed but not released QoS2 packet ids This function should be called before receive the first publish.
pids | packet ids |
void async_mqtt::basic_endpoint< Role, PacketIdBytes, 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::basic_endpoint< Role, PacketIdBytes, NextLayer >::set_auto_ping_response | ( | bool | val | ) |
auto pingreq response setter. Should be called before send()/recv() call.
val | if true, puback, pubrec, pubrel, and pubcomp are automatically sent |
void async_mqtt::basic_endpoint< Role, PacketIdBytes, NextLayer >::set_auto_pub_response | ( | bool | val | ) |
auto publish response setter. Should be called before send()/recv() call.
val | if true, puback, pubrec, pubrel, and pubcomp are automatically sent |
void async_mqtt::basic_endpoint< Role, PacketIdBytes, 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::basic_endpoint< Role, PacketIdBytes, 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::basic_endpoint< Role, PacketIdBytes, 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::basic_endpoint< Role, PacketIdBytes, NextLayer >::set_pingreq_send_interval | ( | std::chrono::milliseconds | duration | ) |
Set PINGREQ packet sending interval.
duration | if zero, timer is not set; otherwise duration is set. The minimum resolution is in milliseconds. |
void async_mqtt::basic_endpoint< Role, PacketIdBytes, 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. |