async_mqtt 5.0.0
|
MQTT endpoint corresponding to the connection. More...
#include <endpoint.hpp>
Inherits std::enable_shared_from_this< basic_endpoint< Role, PacketIdBytes, Strand, NextLayer > >.
Public Types | |
using | next_layer_type = NextLayer |
The type given as NextLayer. | |
using | strand_type = typename stream_type::strand_type |
The type of stand that is used MQTT stream exclusive control. | |
using | packet_variant_type = basic_packet_variant<PacketIdBytes> |
Type of packet_variant. | |
using | packet_id_t = typename packet_id_type<PacketIdBytes>::type |
Type of MQTT Packet Identifier. | |
Public Member Functions | |
strand_type const & | strand () const |
strand getter | |
strand_type & | strand () |
strand getter | |
bool | in_strand () const |
strand checker | |
next_layer_type const & | next_layer () const |
next_layer getter | |
next_layer_type & | next_layer () |
next_layer getter | |
auto const & | lowest_layer () const |
lowest_layer getter | |
auto & | 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_ms (std::size_t ms) |
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. | |
template<typename CompletionToken > | |
auto | acquire_unique_packet_id (CompletionToken &&token) |
acuire unique packet_id. | |
template<typename CompletionToken > | |
auto | acquire_unique_packet_id_wait_until (CompletionToken &&token) |
acuire unique packet_id. If packet_id is fully acquired, then wait until released. | |
template<typename CompletionToken > | |
auto | register_packet_id (packet_id_t packet_id, CompletionToken &&token) |
register packet_id. | |
template<typename CompletionToken > | |
auto | release_packet_id (packet_id_t packet_id, CompletionToken &&token) |
release packet_id. | |
template<typename Packet , typename CompletionToken > | |
auto | send (Packet packet, CompletionToken &&token) |
send packet users can call send() before the previous send()'s CompletionToken is invoked | |
template<typename CompletionToken > | |
auto | recv (CompletionToken &&token) |
receive packet users CANNOT call recv() before the previous recv()'s CompletionToken is invoked | |
template<typename CompletionToken > | |
auto | recv (std::set< control_packet_type > types, CompletionToken &&token) |
receive packet users CANNOT call recv() before the previous recv()'s CompletionToken is invoked if packet is not filterd, then next recv() starts automatically. if receive error happenes, then token would be invoked. | |
template<typename CompletionToken > | |
auto | recv (filter fil, std::set< control_packet_type > types, CompletionToken &&token) |
receive packet users CANNOT call recv() before the previous recv()'s CompletionToken is invoked if packet is not filterd, then next recv() starts automatically. if receive error happenes, then token would be invoked. @params fil if match then matched types are targets. if except then not matched types are targets. | |
template<typename CompletionToken > | |
auto | close (CompletionToken &&token) |
close the underlying connection | |
template<typename CompletionToken > | |
auto | restore_packets (std::vector< basic_store_packet_variant< PacketIdBytes > > pvs, CompletionToken &&token) |
restore packets the restored packets would automatically send when CONNACK packet is received | |
template<typename CompletionToken > | |
auto | get_stored_packets (CompletionToken &&token) const |
get stored packets sotred packets mean inflight packets. | |
optional< packet_id_t > | acquire_unique_packet_id () |
acuire unique packet_id. | |
bool | register_packet_id (packet_id_t pid) |
register packet_id. | |
void | release_packet_id (packet_id_t pid) |
release packet_id. | |
std::set< packet_id_t > | 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< packet_id_t > 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 (packet_id_t pid) const |
Get MQTT PUBLISH packet processing status. | |
void | regulate_for_store (v5::basic_publish_packet< PacketIdBytes > &packet) 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. | |
Static Public Member Functions | |
template<typename... Args> | |
static std::shared_ptr< this_type > | create (protocol_version ver, Args &&... args) |
create | |
Static Public Attributes | |
static constexpr std::size_t | packet_id_bytes = PacketIdBytes |
The value given as PacketIdBytes. | |
Related Symbols | |
(Note that these are not member symbols.) | |
template<role Role, typename NextLayer > | |
using | endpoint = basic_endpoint<Role, 2, as::strand, NextLayer> |
Type alias of basic_endpoint (PacketIdBytes=2, Strand=boost::asio::strand). This is for typical usecase. | |
template<role Role, typename NextLayer > | |
using | endpoint_st = basic_endpoint<Role, 2, null_strand, NextLayer> |
Type alias of basic_endpoint (PacketIdBytes=2, Strand=null_strand). This is only for single threaded environment. | |
MQTT endpoint corresponding to the connection.
Role | role for packet sendable checking |
PacketIdBytes | MQTT spec is 2. You can use endpoint for that. |
Strand | strand class template type. By default boost::asio::strand<T> should be used. You can replace it with null_strand if you run the endpoint on single thread environment. |
NextLayer | Just next layer for basic_endpoint. mqtt, mqtts, ws, and wss are predefined. |
|
inline |
acuire unique packet_id.
|
inline |
acuire unique packet_id.
token | the param is optional<packet_id_t> |
|
inline |
acuire unique packet_id. If packet_id is fully acquired, then wait until released.
token | the param is packet_id_t |
|
inline |
close the underlying connection
token | the param is void |
|
inlinestatic |
create
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. There are predefined next layer types: protocol::mqtt, protocol::mqtts, protocol::ws, and protocol::wss. |
|
inline |
get MQTT protocol version
|
inline |
Get processed but not released QoS2 packet ids This function should be called after disconnection.
|
inline |
get stored packets sotred packets mean inflight packets.
|
inline |
get stored packets sotred packets mean inflight packets.
token | the param is std::vector<basic_store_packet_variant<PacketIdBytes>> |
|
inline |
strand checker
|
inline |
Get MQTT PUBLISH packet processing status.
pid | packet_id corresponding to the publish packet. |
|
inline |
lowest_layer getter
|
inline |
lowest_layer getter
|
inline |
next_layer getter
|
inline |
next_layer getter
|
inline |
|
inline |
receive packet users CANNOT call recv() before the previous recv()'s CompletionToken is invoked if packet is not filterd, then next recv() starts automatically. if receive error happenes, then token would be invoked. @params fil if match
then matched types are targets. if except
then not matched types are targets.
types | target control_packet_types |
token | the param is packet_variant_type |
|
inline |
receive packet users CANNOT call recv() before the previous recv()'s CompletionToken is invoked 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 | the param is packet_variant_type |
|
inline |
register packet_id.
packet_id | packet_id to register |
token | the param is bool. If true, success, otherwise the packet_id has already been used. |
|
inline |
register packet_id.
packet_id | packet_id to register |
|
inline |
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 |
|
inline |
release packet_id.
packet_id | packet_id to release |
token | the param is void |
|
inline |
release packet_id.
packet_id | packet_id to release |
|
inline |
restore packets the restored packets would automatically send when CONNACK packet is received
pvs | packets to restore |
|
inline |
restore packets the restored packets would automatically send when CONNACK packet is received
pvs | packets to restore |
token | the param is void |
|
inline |
Restore processed but not released QoS2 packet ids This function should be called before receive the first publish.
pids | packet ids |
|
inline |
send packet users can call send() before the previous send()'s CompletionToken is invoked
packet | packet to send |
token | the param is system_error |
|
inline |
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. |
|
inline |
auto pingreq response setter. Should be called before send()/recv() call.
val | if true, puback, pubrec, pubrel, and pubcomp are automatically sent |
|
inline |
auto publish response setter. Should be called before send()/recv() call.
val | if true, puback, pubrec, pubrel, and pubcomp are automatically sent |
|
inline |
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. |
|
inline |
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. |
|
inline |
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.
val | if 0, timer is not set, otherwise set val milliseconds. |
|
inline |
strand getter
|
inline |
strand getter
|
related |
Type alias of basic_endpoint (PacketIdBytes=2, Strand=boost::asio::strand). This is for typical usecase.
Role | role for packet sendable checking |
NextLayer | Just next layer for basic_endpoint. mqtt, mqtts, ws, and wss are predefined. |
|
related |
Type alias of basic_endpoint (PacketIdBytes=2, Strand=null_strand). This is only for single threaded environment.
Role | role for packet sendable checking |
NextLayer | Just next layer for basic_endpoint. mqtt, mqtts, ws, and wss are predefined. |