7#if !defined(ASYNC_MQTT_PACKET_V5_CONNECT_HPP)
8#define ASYNC_MQTT_PACKET_V5_CONNECT_HPP
13#include <async_mqtt/buffer_to_packet_variant.hpp>
14#include <async_mqtt/error.hpp>
16#include <async_mqtt/packet/control_packet_type.hpp>
17#include <async_mqtt/packet/will.hpp>
18#include <async_mqtt/packet/property_variant.hpp>
20#include <async_mqtt/util/buffer.hpp>
21#include <async_mqtt/util/variable_bytes.hpp>
22#include <async_mqtt/util/static_vector.hpp>
29namespace async_mqtt::v5 {
31namespace as = boost::asio;
81 std::uint16_t keep_alive_sec,
83 std::optional<std::string>
user_name = std::nullopt,
84 std::optional<std::string>
password = std::nullopt,
120 std::uint16_t keep_alive_sec,
122 std::optional<will> w,
123 std::optional<std::string>
user_name = std::nullopt,
124 std::optional<std::string>
password = std::nullopt,
199 template <std::
size_t PacketIdBytesArg>
203#if defined(ASYNC_MQTT_UNIT_TEST_FOR_PACKET)
204 friend struct ::ut_packet::v5_connect;
205 friend struct ::ut_packet::v5_connect_error;
212 std::uint8_t fixed_header_;
215 std::size_t remaining_length_;
216 static_vector<char, 4> remaining_length_buf_;
218 static_vector<char, 7> protocol_name_and_level_;
220 static_vector<char, 2> client_id_length_buf_;
223 static_vector<char, 2> will_topic_length_buf_;
225 static_vector<char, 2> will_message_length_buf_;
226 std::size_t will_property_length_;
227 static_vector<char, 4> will_property_length_buf_;
231 static_vector<char, 2> user_name_length_buf_;
233 static_vector<char, 2> password_length_buf_;
235 static_vector<char, 2> keep_alive_buf_;
237 std::size_t property_length_;
238 static_vector<char, 4> property_length_buf_;
286#if !defined(ASYNC_MQTT_SEPARATE_COMPILATION)
287#include <async_mqtt/packet/impl/v5_connect.ipp>
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 CONNECT packet (v5)
Definition v5_connect.hpp:49
bool operator<(connect_packet const &lhs, connect_packet const &rhs)
less than operator
connect_packet(bool clean_start, std::uint16_t keep_alive_sec, std::string client_id, std::optional< std::string > user_name=std::nullopt, std::optional< std::string > password=std::nullopt, properties props={})
constructor
connect_packet(bool clean_start, std::uint16_t keep_alive_sec, std::string client_id, std::optional< will > w, std::optional< std::string > user_name=std::nullopt, std::optional< std::string > password=std::nullopt, properties props={})
constructor
std::size_t size() const
Get packet size.
properties const & props() const
Get properties.
std::optional< std::string > user_name() const
Get user_name.
std::uint16_t keep_alive() const
Get keep_alive.
std::vector< as::const_buffer > const_buffer_sequence() const
Create const buffer sequence it is for boost asio APIs.
bool clean_start() const
Get clean_start.
bool operator==(connect_packet const &lhs, connect_packet const &rhs)
equal operator
std::ostream & operator<<(std::ostream &o, connect_packet const &v)
stream output operator
std::string client_id() const
Get client_id.
std::optional< will > get_will() const
Get will.
static constexpr control_packet_type type()
Get MQTT control packet type.
Definition v5_connect.hpp:132
std::size_t num_of_const_buffer_sequence() const
Get number of element of const_buffer_sequence.
std::optional< std::string > password() const
Get password.
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