7#if !defined(ASYNC_MQTT_PACKET_V3_1_1_CONNECT_HPP)
8#define ASYNC_MQTT_PACKET_V3_1_1_CONNECT_HPP
10#include <async_mqtt/buffer_to_packet_variant.hpp>
11#include <async_mqtt/util/buffer.hpp>
13#include <async_mqtt/util/static_vector.hpp>
15#include <async_mqtt/packet/control_packet_type.hpp>
16#include <async_mqtt/packet/will.hpp>
23namespace async_mqtt::v3_1_1 {
25namespace as = boost::asio;
72 std::uint16_t keep_alive_sec,
74 std::optional<std::string>
user_name = std::nullopt,
75 std::optional<std::string>
password = std::nullopt
108 std::uint16_t keep_alive_sec,
110 std::optional<will> w,
111 std::optional<std::string>
user_name = std::nullopt,
112 std::optional<std::string>
password = std::nullopt
180 template <std::
size_t PacketIdBytesArg>
184#if defined(ASYNC_MQTT_UNIT_TEST_FOR_PACKET)
185 friend struct ::ut_packet::v311_connect;
186 friend struct ::ut_packet::v311_connect_error;
193 std::uint8_t fixed_header_;
196 std::size_t remaining_length_;
197 static_vector<char, 4> remaining_length_buf_;
199 static_vector<char, 7> protocol_name_and_level_;
201 static_vector<char, 2> client_id_length_buf_;
204 static_vector<char, 2> will_topic_length_buf_;
206 static_vector<char, 2> will_message_length_buf_;
209 static_vector<char, 2> user_name_length_buf_;
211 static_vector<char, 2> password_length_buf_;
213 static_vector<char, 2> keep_alive_buf_;
257#if !defined(ASYNC_MQTT_SEPARATE_COMPILATION)
258#include <async_mqtt/packet/impl/v3_1_1_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 (v3.1.1)
Definition v3_1_1_connect.hpp:42
std::optional< std::string > password() const
Get password.
bool operator<(connect_packet const &lhs, connect_packet const &rhs)
less than operator
static constexpr control_packet_type type()
Get MQTT control packet type.
Definition v3_1_1_connect.hpp:119
std::size_t size() const
Get packet size.
std::optional< will > get_will() const
Get will.
std::string client_id() const
Get client_id.
std::vector< as::const_buffer > const_buffer_sequence() const
Create const buffer sequence it is for boost asio APIs.
bool clean_session() const
Get clean_session.
bool operator==(connect_packet const &lhs, connect_packet const &rhs)
equal operator
connect_packet(bool clean_session, 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)
constructor
std::uint16_t keep_alive() const
Get keep_alive.
std::optional< std::string > user_name() const
Get user_name.
std::size_t num_of_const_buffer_sequence() const
Get number of element of const_buffer_sequence.
std::ostream & operator<<(std::ostream &o, connect_packet const &v)
stream output operator
connect_packet(bool clean_session, 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)
constructor
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