7#if !defined(ASYNC_MQTT_PACKET_V3_1_1_PUBACK_HPP)
8#define ASYNC_MQTT_PACKET_V3_1_1_PUBACK_HPP
13#include <boost/numeric/conversion/cast.hpp>
15#include <async_mqtt/exception.hpp>
16#include <async_mqtt/buffer.hpp>
18#include <async_mqtt/util/move.hpp>
19#include <async_mqtt/util/static_vector.hpp>
20#include <async_mqtt/util/endian_convert.hpp>
22#include <async_mqtt/packet/packet_id_type.hpp>
23#include <async_mqtt/packet/fixed_header.hpp>
25namespace async_mqtt::v3_1_1 {
27namespace as = boost::asio;
39template <std::
size_t PacketIdBytes>
42 using packet_id_t =
typename packet_id_type<PacketIdBytes>::type;
53 all_[0] =
static_cast<char>(make_fixed_header(control_packet_type::puback, 0b0000));
63 "v3_1_1::puback_packet fixed_header doesn't exist"
66 all_.push_back(buf.front());
68 auto cpt_opt = get_control_packet_type_with_check(
static_cast<std::uint8_t
>(all_.back()));
72 "v3_1_1::puback_packet fixed_header is invalid"
80 "v3_1_1::puback_packet remaining_length doesn't exist"
83 all_.push_back(buf.front());
85 if (
static_cast<std::uint8_t
>(all_.back()) != PacketIdBytes) {
88 "v3_1_1::puback_packet remaining_length is invalid"
93 if (buf.size() != PacketIdBytes) {
96 "v3_1_1::puback_packet variable header doesn't match its length"
99 std::copy(buf.begin(), buf.end(), std::back_inserter(all_));
102 constexpr control_packet_type type()
const {
103 return control_packet_type::puback;
112 std::vector<as::const_buffer>
ret;
114 ret.emplace_back(as::buffer(all_.data(), all_.size()));
146template <std::
size_t PacketIdBytes>
150 "pid:" <<
v.packet_id() <<
Definition packet_variant.hpp:49
buffer that has string_view interface This class provides string_view interface. This class hold stri...
Definition buffer.hpp:30
MQTT PUBACK packet (v3.1.1)
Definition v3_1_1_puback.hpp:40
basic_puback_packet(packet_id_t packet_id)
constructor
Definition v3_1_1_puback.hpp:48
static constexpr std::size_t num_of_const_buffer_sequence()
Get number of element of const_buffer_sequence.
Definition v3_1_1_puback.hpp:130
std::vector< as::const_buffer > const_buffer_sequence() const
Create const buffer sequence it is for boost asio APIs.
Definition v3_1_1_puback.hpp:111
packet_id_t packet_id() const
Get packet_id.
Definition v3_1_1_puback.hpp:138
std::size_t size() const
Get packet size.
Definition v3_1_1_puback.hpp:122