async_mqtt 9.0.1
Loading...
Searching...
No Matches
async_mqtt::v5::connect_packet Class Reference

MQTT CONNECT packet (v5) More...

#include <v5_connect.hpp>

Public Member Functions

 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::vector< as::const_buffer > const_buffer_sequence () const
 Create const buffer sequence it is for boost asio APIs.
 
std::size_t size () const
 Get packet size.
 
std::size_t num_of_const_buffer_sequence () const
 Get number of element of const_buffer_sequence.
 
bool clean_start () const
 Get clean_start.
 
std::uint16_t keep_alive () const
 Get keep_alive.
 
std::string client_id () const
 Get client_id.
 
std::optional< std::string > user_name () const
 Get user_name.
 
std::optional< std::string > password () const
 Get password.
 
std::optional< willget_will () const
 Get will.
 
properties const & props () const
 Get properties.
 

Static Public Member Functions

static constexpr control_packet_type type ()
 Get MQTT control packet type.
 

Related Symbols

(Note that these are not member symbols.)

bool operator< (connect_packet const &lhs, connect_packet const &rhs)
 less than operator
 
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
 

Detailed Description

MQTT CONNECT packet (v5)

Only MQTT client can send this packet.
See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901033

Thread Safety

  • Distinct objects: Safe
  • Shared objects: Unsafe

Requirements

Constructor & Destructor Documentation

◆ connect_packet() [1/2]

async_mqtt::v5::connect_packet::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 = {} )
explicit

constructor

Parameters
clean_startWhen the endpoint sends CONNECT packet with clean_start is true, then stored packets are erased. When the endpoint receives CONNECT packet with clean_start is false, then the endpoint start storing PUBLISH packet (QoS1 and QoS2) and PUBREL packet that would send by the endpoint until the corresponding response would be received.
See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901039
keep_alive_secWhen the endpoint sends CONNECT packet with keep_alive_sec, then the endpoint start sending PINGREQ packet keep_alive_sec after the last packet is sent. When the endpoint receives CONNECT packet with keep_alive_sec, then start keep_alive_sec * 1.5 timer. The timer is reset if any packet is received. If the timer is fired, then the endpoint close the underlying layer automatically. At that time, if the endpoint recv() is called, then the CompletionToken is invoked with system_error.
See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901045
client_idMQTT ClientIdentifier. It is the request to the broker for generating ClientIdentifier if it is empty string.
See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901059
user_nameMQTT UserName. It is often used for authentication.
See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901071
passwordMQTT Password. It is often used for authentication.
See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901072
propsConnect properties.
See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901046

◆ connect_packet() [2/2]

async_mqtt::v5::connect_packet::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 = {} )
explicit

constructor

Parameters
clean_startWhen the endpoint sends CONNECT packet with clean_start is true, then stored packets are erased. When the endpoint receives CONNECT packet with clean_start is false, then the endpoint start storing PUBLISH packet (QoS1 and QoS2) and PUBREL packet that would send by the endpoint until the corresponding response would be received.
See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901039
keep_alive_secWhen the endpoint sends CONNECT packet with keep_alive_sec, then the endpoint start sending PINGREQ packet keep_alive_sec after the last packet is sent. When the endpoint receives CONNECT packet with keep_alive_sec, then start keep_alive_sec * 1.5 timer. The timer is reset if any packet is received. If the timer is fired, then the endpoint close the underlying layer automatically. At that time, if the endpoint recv() is called, then the CompletionToken is invoked with system_error.
See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901045
client_idMQTT ClientIdentifier. It is the request to the broker for generating ClientIdentifier if it is empty string.
See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901059
wMQTT Will
See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901060
user_nameMQTT UserName. It is often used for authentication.
See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901071
passwordMQTT Password. It is often used for authentication.
See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901072
propsConnect properties.
See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901046

Member Function Documentation

◆ clean_start()

bool async_mqtt::v5::connect_packet::clean_start ( ) const

Get clean_start.

Returns
clean_start

◆ client_id()

std::string async_mqtt::v5::connect_packet::client_id ( ) const

Get client_id.

Returns
client_id

◆ const_buffer_sequence()

std::vector< as::const_buffer > async_mqtt::v5::connect_packet::const_buffer_sequence ( ) const

Create const buffer sequence it is for boost asio APIs.

Returns
const buffer sequence

◆ get_will()

std::optional< will > async_mqtt::v5::connect_packet::get_will ( ) const

Get will.

Returns
will

◆ keep_alive()

std::uint16_t async_mqtt::v5::connect_packet::keep_alive ( ) const

Get keep_alive.

Returns
keep_alive

◆ num_of_const_buffer_sequence()

std::size_t async_mqtt::v5::connect_packet::num_of_const_buffer_sequence ( ) const

Get number of element of const_buffer_sequence.

Returns
number of element of const_buffer_sequence

◆ password()

std::optional< std::string > async_mqtt::v5::connect_packet::password ( ) const

Get password.

Returns
password

◆ props()

properties const & async_mqtt::v5::connect_packet::props ( ) const

Get properties.

Returns
properties

◆ size()

std::size_t async_mqtt::v5::connect_packet::size ( ) const

Get packet size.

Returns
packet size

◆ type()

static constexpr control_packet_type async_mqtt::v5::connect_packet::type ( )
inlinestaticconstexpr

Get MQTT control packet type.

Returns
control packet type

◆ user_name()

std::optional< std::string > async_mqtt::v5::connect_packet::user_name ( ) const

Get user_name.

Returns
user_name

Friends And Related Symbol Documentation

◆ operator<()

bool operator< ( connect_packet const & lhs,
connect_packet const & rhs )
related

less than operator

Parameters
lhscompare target
rhscompare target
Returns
true if the lhs less than the rhs, otherwise false.

Requirements

◆ operator<<()

std::ostream & operator<< ( std::ostream & o,
connect_packet const & v )
related

stream output operator

Parameters
ooutput stream
vtarget
Returns
output stream

Requirements

◆ operator==()

bool operator== ( connect_packet const & lhs,
connect_packet const & rhs )
related

equal operator

Parameters
lhscompare target
rhscompare target
Returns
true if the lhs equal to the rhs, otherwise false.

Requirements


The documentation for this class was generated from the following file: