7#if !defined(ASYNC_MQTT_PACKET_STORE_PACKET_VARIANT_HPP)
8#define ASYNC_MQTT_PACKET_STORE_PACKET_VARIANT_HPP
12#include <async_mqtt/util/overload.hpp>
13#include <async_mqtt/packet/store_packet_variant_fwd.hpp>
14#include <async_mqtt/packet/packet_id_type.hpp>
15#include <async_mqtt/packet/v3_1_1_publish.hpp>
16#include <async_mqtt/packet/v3_1_1_pubrel.hpp>
17#include <async_mqtt/packet/v5_publish.hpp>
18#include <async_mqtt/packet/v5_pubrel.hpp>
40template <std::
size_t PacketIdBytes>
41class basic_store_packet_variant {
65 var_{force_move(packet)}
74 var_{force_move(packet)}
98 var_{force_move(packet)}
107 var_{force_move(packet)}
114 template <
typename Func>
118 std::forward<Func>(func),
127 template <
typename Func>
131 std::forward<Func>(func),
140 template <
typename Func>
144 std::forward<Func>(func),
158 return p.const_buffer_sequence();
162 return std::vector<as::const_buffer>{};
176 return p.packet_id();
189 [] (
auto const& p) -> std::size_t {
204 std::uint32_t ret = 0;
206 for (
auto const& prop : p.props()) {
222 return std::uint32_t(0);
237 for (
auto& prop : p.props()) {
266 using variant_t = std::variant<
277template <std::
size_t PacketIdBytes>
278inline std::ostream& operator<<(std::ostream& o, basic_store_packet_variant<PacketIdBytes>
const& v) {
281 [&] (
auto const& p) {
response_packet response_packet_type() const
Get response packet type corresponding to this packet.
Definition store_packet_variant.hpp:261
auto visit(Func &&func) const &
visit to variant
Definition store_packet_variant.hpp:115
basic_store_packet_variant(v3_1_1::basic_pubrel_packet< PacketIdBytes > packet)
constructor
Definition store_packet_variant.hpp:72
basic_store_packet_variant(v5::basic_publish_packet< PacketIdBytes > packet)
constructor
Definition store_packet_variant.hpp:81
std::vector< as::const_buffer > const_buffer_sequence() const
Create const buffer sequence it is for boost asio APIs.
Definition store_packet_variant.hpp:154
std::size_t size() const
Get packet size.
Definition store_packet_variant.hpp:186
basic_store_packet_variant(v5::basic_pubrel_packet< PacketIdBytes > packet)
constructor
Definition store_packet_variant.hpp:105
auto visit(Func &&func) &&
visit to variant
Definition store_packet_variant.hpp:141
basic_packet_id_type< PacketIdBytes >::type packet_id() const
Get packet id.
Definition store_packet_variant.hpp:172
void update_message_expiry_interval(std::uint32_t val) const
Update MessageExpiryInterval property.
Definition store_packet_variant.hpp:232
auto visit(Func &&func) &
visit to variant
Definition store_packet_variant.hpp:128
basic_store_packet_variant(v3_1_1::basic_publish_packet< PacketIdBytes > packet)
constructor
Definition store_packet_variant.hpp:48
std::uint32_t get_message_expiry_interval() const
Get MessageExpiryInterval property value.
Definition store_packet_variant.hpp:200
message_expiry_interval property
Definition property.hpp:193
MQTT PUBLISH packet (v3.1.1)
Definition v3_1_1_publish.hpp:61
constexpr pub::opts opts() const
Get publish_options.
Definition v3_1_1_publish.hpp:165
MQTT PUBREL packet (v3.1.1)
Definition v3_1_1_pubrel.hpp:55
MQTT PUBLISH packet (v5)
Definition v5_publish.hpp:63
constexpr pub::opts opts() const
Get publish_options.
Definition v5_publish.hpp:172
MQTT PUBREL packet (v5)
Definition v5_pubrel.hpp:56
sys::error_code error_code
sys is a namespace alias of boost::sytem.
Definition error.hpp:56
sys::system_error system_error
system_error is a type alias of boost::sytem::system_error.
Definition error.hpp:67
error_code make_error_code(mqtt_error v)
make error code
@ packet_not_allowed_to_store
Packet is not allowd to be stored.
@ exactly_once
Exactly once delivery.
@ at_least_once
At least once delivery.
response_packet
corresponding response packet
Definition store_packet_variant.hpp:31
@ v5_pubrec
stored packet is v5_basic_publish_packet QoS2
@ v3_1_1_pubcomp
stored packet is v3_1_1_basic_pubrel_packet
@ v3_1_1_pubrec
stored packet is v3_1_1_basic_publish_packet QoS2
@ v5_pubcomp
stored packet is v5_basic_rel_packet
@ v3_1_1_puback
stored packet is v3_1_1_basic_publish_packet QoS1
@ v5_puback
stored packet is v5_basic_publish_packet QoS1
packet idenfitifer type class template
Definition packet_id_type.hpp:25
constexpr qos get_qos() const
Get qos.
Definition pubopts.hpp:248