async_mqtt 4.1.0
Loading...
Searching...
No Matches
async_mqtt::v3_1_1::basic_publish_packet< PacketIdBytes > Class Template Reference

MQTT PUBLISH packet (v3.1.1) More...

#include <v3_1_1_publish.hpp>

Public Member Functions

template<typename BufferSequence , typename std::enable_if< is_buffer_sequence< std::decay_t< BufferSequence > >::value, std::nullptr_t >::type = nullptr>
 basic_publish_packet (packet_id_t packet_id, buffer topic_name, BufferSequence payloads, pub::opts pubopts)
 constructor
 
template<typename BufferSequence , typename std::enable_if< is_buffer_sequence< std::decay_t< BufferSequence > >::value, std::nullptr_t >::type = nullptr>
 basic_publish_packet (buffer topic_name, BufferSequence payloads, pub::opts pubopts)
 constructor for QoS0 This constructor doesn't have packet_id parameter. The packet_id is set to 0 internally and not send actually.
 
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.
 
packet_id_t packet_id () const
 Get packet id.
 
constexpr pub::opts opts () const
 Get publish_options.
 
constexpr buffer consttopic () const
 Get topic name.
 
std::vector< buffer > constpayload () const
 Get payload.
 
auto payload_range () const
 Get payload range.
 
constexpr void set_dup (bool dup)
 Set dup flag.
 

Related Symbols

(Note that these are not member symbols.)

using publish_packet = basic_publish_packet<2>
 Type alias of basic_publish_packet (PacketIdBytes=2).
 

Detailed Description

template<std::size_t PacketIdBytes>
class async_mqtt::v3_1_1::basic_publish_packet< PacketIdBytes >

MQTT PUBLISH packet (v3.1.1)

Template Parameters
PacketIdBytessize of packet_id

If both the client and the broker keeping the session, QoS1 and QoS2 PUBLISH packet is stored in the endpoint for resending if disconnect/reconnect happens. In addition, the client can sent the packet at offline. The packets are stored and will send after the next connection is established. If the session doesn' exist or lost, then the stored packets are erased.
See http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718037

Constructor & Destructor Documentation

◆ basic_publish_packet() [1/2]

template<std::size_t PacketIdBytes>
template<typename BufferSequence , typename std::enable_if< is_buffer_sequence< std::decay_t< BufferSequence > >::value, std::nullptr_t >::type = nullptr>
async_mqtt::v3_1_1::basic_publish_packet< PacketIdBytes >::basic_publish_packet ( packet_id_t packet_id,
buffer topic_name,
BufferSequence payloads,
pub::opts pubopts )
inline

constructor

Template Parameters
BufferSequenceType of the payload
Parameters
packet_idMQTT PacketIdentifier. If QoS0 then it must be 0. You can use no packet_id version constructor. If QoS is 0 or 1 then, the packet_id must be acquired by basic_endpoint::acquire_unique_packet_id(), or must be registered by basic_endpoint::register_packet_id().
If QoS0, the packet_id is not sent actually.
See http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc385349268
topic_nameMQTT TopicName
See http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc385349267
payloadsThe body message of the packet. It could be a single buffer of multiple buffer sequence.
See http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc384800413
puboptsPublish Options. It contains the following elements:
DUP See http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc385349262
QoS See http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc385349263
RETAIN See http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc385349265

◆ basic_publish_packet() [2/2]

template<std::size_t PacketIdBytes>
template<typename BufferSequence , typename std::enable_if< is_buffer_sequence< std::decay_t< BufferSequence > >::value, std::nullptr_t >::type = nullptr>
async_mqtt::v3_1_1::basic_publish_packet< PacketIdBytes >::basic_publish_packet ( buffer topic_name,
BufferSequence payloads,
pub::opts pubopts )
inline

constructor for QoS0 This constructor doesn't have packet_id parameter. The packet_id is set to 0 internally and not send actually.

Template Parameters
BufferSequenceType of the payload
Parameters
topic_nameMQTT TopicName
See http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc385349267
payloadsThe body message of the packet. It could be a single buffer of multiple buffer sequence.
See http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc384800413
puboptsPublish Options. It contains the following elements:
DUP See http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc385349262
QoS See http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc385349263
RETAIN See http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc385349265

Member Function Documentation

◆ const_buffer_sequence()

template<std::size_t PacketIdBytes>
std::vector< as::const_buffer > async_mqtt::v3_1_1::basic_publish_packet< PacketIdBytes >::const_buffer_sequence ( ) const
inline

Create const buffer sequence it is for boost asio APIs.

Returns
const buffer sequence

◆ num_of_const_buffer_sequence()

template<std::size_t PacketIdBytes>
std::size_t async_mqtt::v3_1_1::basic_publish_packet< PacketIdBytes >::num_of_const_buffer_sequence ( ) const
inline

Get number of element of const_buffer_sequence.

Returns
number of element of const_buffer_sequence

◆ opts()

template<std::size_t PacketIdBytes>
constexpr pub::opts async_mqtt::v3_1_1::basic_publish_packet< PacketIdBytes >::opts ( ) const
inlineconstexpr

Get publish_options.

Returns
publish_options.

◆ packet_id()

template<std::size_t PacketIdBytes>
packet_id_t async_mqtt::v3_1_1::basic_publish_packet< PacketIdBytes >::packet_id ( ) const
inline

Get packet id.

Returns
packet_id

◆ payload()

template<std::size_t PacketIdBytes>
std::vector< buffer > const & async_mqtt::v3_1_1::basic_publish_packet< PacketIdBytes >::payload ( ) const
inline

Get payload.

Returns
payload

◆ payload_range()

template<std::size_t PacketIdBytes>
auto async_mqtt::v3_1_1::basic_publish_packet< PacketIdBytes >::payload_range ( ) const
inline

Get payload range.

Returns
A pair of forward iterators

◆ set_dup()

template<std::size_t PacketIdBytes>
constexpr void async_mqtt::v3_1_1::basic_publish_packet< PacketIdBytes >::set_dup ( bool dup)
inlineconstexpr

Set dup flag.

Parameters
dupflag value to set

◆ size()

template<std::size_t PacketIdBytes>
std::size_t async_mqtt::v3_1_1::basic_publish_packet< PacketIdBytes >::size ( ) const
inline

Get packet size.

Returns
packet size

◆ topic()

template<std::size_t PacketIdBytes>
constexpr buffer const & async_mqtt::v3_1_1::basic_publish_packet< PacketIdBytes >::topic ( ) const
inlineconstexpr

Get topic name.

Returns
topic name

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