async_mqtt 9.0.1
Loading...
Searching...
No Matches
async_mqtt::v5::basic_publish_packet< PacketIdBytes > Class Template Reference

MQTT PUBLISH packet (v5) More...

#include <v5_publish.hpp>

Public Member Functions

template<typename StringViewLike , typename Payload , std::enable_if_t< std::is_convertible_v< std::decay_t< StringViewLike >, std::string_view > &&detail::is_payload< Payload >(), std::nullptr_t > = nullptr>
 basic_publish_packet (typename basic_packet_id_type< PacketIdBytes >::type packet_id, StringViewLike &&topic_name, Payload &&payloads, pub::opts pubopts, properties props={})
 constructor
 
template<typename StringViewLike , typename Payload , std::enable_if_t< std::is_convertible_v< std::decay_t< StringViewLike >, std::string_view > &&detail::is_payload< Payload >(), std::nullptr_t > = nullptr>
 basic_publish_packet (StringViewLike &&topic_name, Payload &&payloads, pub::opts pubopts, properties props={})
 constructor for QoS0
 
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.
 
basic_packet_id_type< PacketIdBytes >::type packet_id () const
 Get packet id.
 
constexpr pub::opts opts () const
 Get publish_options.
 
std::string topic () const
 Get topic name.
 
buffer const & topic_as_buffer () const
 Get topic as a buffer.
 
std::string payload () const
 Get payload.
 
auto payload_range () const
 Get payload range.
 
std::vector< buffer > const & payload_as_buffer () const
 Get payload as a sequence of buffer.
 
constexpr void set_dup (bool dup)
 Set dup flag.
 
properties const & props () const
 Get properties.
 
void remove_topic_add_topic_alias (topic_alias_type val)
 Remove topic and add topic_alias This is for applying topic_alias.
 
void add_topic_alias (topic_alias_type val)
 Add topic_alias This is for registering topic_alias.
 
void add_topic (std::string topic)
 Add topic This is for extracting topic_alias.
 
void remove_topic_alias ()
 Remove topic alias This is for prepareing to store packet.
 
void remove_topic_alias_add_topic (std::string topic)
 Remove topic and add topic_alias This is for extracting topic from the topic_alias.
 
void update_message_expiry_interval (std::uint32_t val)
 Update MessageExpiryInterval property.
 

Static Public Member Functions

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

Related Symbols

(Note that these are not member symbols.)

using publish_packet = basic_publish_packet<2>
 Type alias of basic_publish_packet (PacketIdBytes=2).
 
template<std::size_t PacketIdBytes>
bool operator< (basic_publish_packet< PacketIdBytes > const &lhs, basic_publish_packet< PacketIdBytes > const &rhs)
 less than operator
 
template<std::size_t PacketIdBytes>
bool operator== (basic_publish_packet< PacketIdBytes > const &lhs, basic_publish_packet< PacketIdBytes > const &rhs)
 equal operator
 
template<std::size_t PacketIdBytes>
std::ostream & operator<< (std::ostream &o, basic_publish_packet< PacketIdBytes > const &v)
 stream output operator
 

Detailed Description

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

MQTT PUBLISH packet (v5)

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 https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901100

Thread Safety

  • Distinct objects: Safe
  • Shared objects: Unsafe

Requirements

Constructor & Destructor Documentation

◆ basic_publish_packet() [1/2]

template<std::size_t PacketIdBytes>
template<typename StringViewLike , typename Payload , std::enable_if_t< std::is_convertible_v< std::decay_t< StringViewLike >, std::string_view > &&detail::is_payload< Payload >(), std::nullptr_t > = nullptr>
async_mqtt::v5::basic_publish_packet< PacketIdBytes >::basic_publish_packet ( typename basic_packet_id_type< PacketIdBytes >::type packet_id,
StringViewLike && topic_name,
Payload && payloads,
pub::opts pubopts,
properties props = {} )
explicit

constructor

Template Parameters
StringViewLikeType of the topic. Any type can convert to std::string_view.
PayloadType of the payload. Any type can convert to std::string_view or its sequence.
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 https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901108
topic_nameMQTT TopicName
See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901107
payloadsThe body message of the packet. It could be a single buffer of multiple buffer sequence.
See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901119
puboptsPublish Options. It contains the following elements:
DUP See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901102
QoS See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901103
RETAIN See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901104
propsPublish properties.
See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901109

◆ basic_publish_packet() [2/2]

template<std::size_t PacketIdBytes>
template<typename StringViewLike , typename Payload , std::enable_if_t< std::is_convertible_v< std::decay_t< StringViewLike >, std::string_view > &&detail::is_payload< Payload >(), std::nullptr_t > = nullptr>
async_mqtt::v5::basic_publish_packet< PacketIdBytes >::basic_publish_packet ( StringViewLike && topic_name,
Payload && payloads,
pub::opts pubopts,
properties props = {} )
explicit

constructor for QoS0

Template Parameters
StringViewLikeType of the topic. Any type can convert to std::string_view.
PayloadType of the payload. Any type can convert to std::string_view or its sequence.
Parameters
topic_nameMQTT TopicName
See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901107
payloadsThe body message of the packet. It could be a single buffer of multiple buffer sequence.
See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901119
puboptsPublish Options. It contains the following elements:
DUP See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901102
QoS See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901103
RETAIN See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901104
propsPublish properties.
See https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901109

Member Function Documentation

◆ add_topic()

template<std::size_t PacketIdBytes>
void async_mqtt::v5::basic_publish_packet< PacketIdBytes >::add_topic ( std::string topic)

Add topic This is for extracting topic_alias.

Parameters
topicto add

◆ add_topic_alias()

template<std::size_t PacketIdBytes>
void async_mqtt::v5::basic_publish_packet< PacketIdBytes >::add_topic_alias ( topic_alias_type val)

Add topic_alias This is for registering topic_alias.

Parameters
valtopic_alias

◆ const_buffer_sequence()

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

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::v5::basic_publish_packet< PacketIdBytes >::num_of_const_buffer_sequence ( ) const

Get number of element of const_buffer_sequence.

Returns
number of element of const_buffer_sequence

◆ opts()

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

Get publish_options.

Returns
publish_options.

◆ packet_id()

template<std::size_t PacketIdBytes>
basic_packet_id_type< PacketIdBytes >::type async_mqtt::v5::basic_publish_packet< PacketIdBytes >::packet_id ( ) const

Get packet id.

Returns
packet_id

◆ payload()

template<std::size_t PacketIdBytes>
std::string async_mqtt::v5::basic_publish_packet< PacketIdBytes >::payload ( ) const

Get payload.

Returns
payload

◆ payload_as_buffer()

template<std::size_t PacketIdBytes>
std::vector< buffer > const & async_mqtt::v5::basic_publish_packet< PacketIdBytes >::payload_as_buffer ( ) const

Get payload as a sequence of buffer.

Returns
payload

◆ payload_range()

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

Get payload range.

Returns
A pair of forward iterators

◆ props()

template<std::size_t PacketIdBytes>
properties const & async_mqtt::v5::basic_publish_packet< PacketIdBytes >::props ( ) const

Get properties.

Returns
properties

◆ remove_topic_add_topic_alias()

template<std::size_t PacketIdBytes>
void async_mqtt::v5::basic_publish_packet< PacketIdBytes >::remove_topic_add_topic_alias ( topic_alias_type val)

Remove topic and add topic_alias This is for applying topic_alias.

Parameters
valtopic_alias

◆ remove_topic_alias_add_topic()

template<std::size_t PacketIdBytes>
void async_mqtt::v5::basic_publish_packet< PacketIdBytes >::remove_topic_alias_add_topic ( std::string topic)

Remove topic and add topic_alias This is for extracting topic from the topic_alias.

Parameters
topictopic_alias

◆ set_dup()

template<std::size_t PacketIdBytes>
void async_mqtt::v5::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::v5::basic_publish_packet< PacketIdBytes >::size ( ) const

Get packet size.

Returns
packet size

◆ topic()

template<std::size_t PacketIdBytes>
std::string async_mqtt::v5::basic_publish_packet< PacketIdBytes >::topic ( ) const

Get topic name.

Returns
topic name

◆ topic_as_buffer()

template<std::size_t PacketIdBytes>
buffer const & async_mqtt::v5::basic_publish_packet< PacketIdBytes >::topic_as_buffer ( ) const

Get topic as a buffer.

Returns
topic name

◆ type()

template<std::size_t PacketIdBytes>
static constexpr control_packet_type async_mqtt::v5::basic_publish_packet< PacketIdBytes >::type ( )
inlinestaticconstexpr

Get MQTT control packet type.

Returns
control packet type

◆ update_message_expiry_interval()

template<std::size_t PacketIdBytes>
void async_mqtt::v5::basic_publish_packet< PacketIdBytes >::update_message_expiry_interval ( std::uint32_t val)

Update MessageExpiryInterval property.

Parameters
valmessage_expiry_interval

Friends And Related Symbol Documentation

◆ operator<()

template<std::size_t PacketIdBytes>
bool operator< ( basic_publish_packet< PacketIdBytes > const & lhs,
basic_publish_packet< PacketIdBytes > const & rhs )
related

less than operator

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

Requirements

◆ operator<<()

template<std::size_t PacketIdBytes>
std::ostream & operator<< ( std::ostream & o,
basic_publish_packet< PacketIdBytes > const & v )
related

stream output operator

Parameters
ooutput stream
vtarget
Returns
output stream

Requirements

◆ operator==()

template<std::size_t PacketIdBytes>
bool operator== ( basic_publish_packet< PacketIdBytes > const & lhs,
basic_publish_packet< PacketIdBytes > 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 files: