async_mqtt 9.0.1
Loading...
Searching...
No Matches
v5_connack.hpp
1// Copyright Takatoshi Kondo 2022
2//
3// Distributed under the Boost Software License, Version 1.0.
4// (See accompanying file LICENSE_1_0.txt or copy at
5// http://www.boost.org/LICENSE_1_0.txt)
6
7#if !defined(ASYNC_MQTT_PACKET_V5_CONNACK_HPP)
8#define ASYNC_MQTT_PACKET_V5_CONNACK_HPP
9
10#include <async_mqtt/buffer_to_packet_variant.hpp>
11#include <async_mqtt/error.hpp>
12
13#include <async_mqtt/packet/control_packet_type.hpp>
14#include <async_mqtt/packet/property_variant.hpp>
15
16#include <async_mqtt/util/buffer.hpp>
17#include <async_mqtt/util/static_vector.hpp>
18
24namespace async_mqtt::v5 {
25
26namespace as = boost::asio;
27
45public:
46
58 bool session_present,
59 connect_reason_code reason_code,
60 properties props = {}
61 );
62
67 static constexpr control_packet_type type() {
69 }
70
76 std::vector<as::const_buffer> const_buffer_sequence() const;
77
82 std::size_t size() const;
83
88 std::size_t num_of_const_buffer_sequence() const;
89
94 bool session_present() const;
95
101
106 properties const& props() const;
107
108private:
109
110 template <std::size_t PacketIdBytesArg>
113
114#if defined(ASYNC_MQTT_UNIT_TEST_FOR_PACKET)
115 friend struct ::ut_packet::v5_connack;
116 friend struct ::ut_packet::v5_connack_error;
117#endif // defined(ASYNC_MQTT_UNIT_TEST_FOR_PACKET)
118
119 // private constructor for internal use
120 explicit connack_packet(buffer buf, error_code& ec);
121
122private:
123 std::uint8_t fixed_header_;
124
125 std::size_t remaining_length_;
126 boost::container::static_vector<char, 4> remaining_length_buf_;
127
128 std::uint8_t connect_acknowledge_flags_;
129
130 connect_reason_code reason_code_;
131
132 std::size_t property_length_;
133 boost::container::static_vector<char, 4> property_length_buf_;
134 properties props_;
135};
136
149bool operator<(connack_packet const& lhs, connack_packet const& rhs);
150
163bool operator==(connack_packet const& lhs, connack_packet const& rhs);
164
177std::ostream& operator<<(std::ostream& o, connack_packet const& v);
178
179} // namespace async_mqtt::v5
180
181#if !defined(ASYNC_MQTT_SEPARATE_COMPILATION)
182#include <async_mqtt/packet/impl/v5_connack.ipp>
183#endif // !defined(ASYNC_MQTT_SEPARATE_COMPILATION)
184
185#endif // ASYNC_MQTT_PACKET_V5_CONNACK_HPP
The varaint type of all packets and system_error.
Definition packet_variant_fwd.hpp:37
buffer that has string_view interface and shared ownership This class is only for advanced usecase su...
Definition buffer.hpp:46
MQTT CONNACK packet (v5)
Definition v5_connack.hpp:44
std::size_t size() const
Get packet size.
properties const & props() const
Get properties.
std::size_t num_of_const_buffer_sequence() const
Get number of element of const_buffer_sequence.
bool session_present() const
Get session present.
connack_packet(bool session_present, connect_reason_code reason_code, properties props={})
constructor
connect_reason_code code() const
Get reason code.
bool operator<(connack_packet const &lhs, connack_packet const &rhs)
less than operator
bool operator==(connack_packet const &lhs, connack_packet const &rhs)
equal operator
std::vector< as::const_buffer > const_buffer_sequence() const
Create const buffer sequence it is for boost asio APIs.
std::ostream & operator<<(std::ostream &o, connack_packet const &v)
stream output operator
static constexpr control_packet_type type()
Get MQTT control packet type.
Definition v5_connack.hpp:67
connect_reason_code
connect reason code It is reported as CONNECT response via CONNACK packet
Definition error.hpp:356
sys::error_code error_code
sys is a namespace alias of boost::sytem.
Definition error.hpp:56
protocol_version
MQTT protocol version.
Definition protocol_version.hpp:29
basic_packet_variant< PacketIdBytes > buffer_to_basic_packet_variant(buffer buf, protocol_version ver, error_code &ec)
create basic_packet_variant from the buffer
control_packet_type
MQTT control packet type.
Definition control_packet_type.hpp:26
std::vector< property_variant > properties
property variant collection type
Definition property_variant.hpp:224