SNode.C
Loading...
Searching...
No Matches
iot::mqtt_fast::packets::Publish Class Reference

#include <Publish.h>

Inheritance diagram for iot::mqtt_fast::packets::Publish:
Collaboration diagram for iot::mqtt_fast::packets::Publish:

Public Member Functions

 Publish (uint16_t packetIdentifier, const std::string &topic, const std::string &message, bool dup=false, uint8_t qoS=0, bool retain=false)
 
 Publish (iot::mqtt_fast::ControlPacketFactory &controlPacketFactory)
 
bool getDup () const
 
uint8_t getQoS () const
 
uint16_t getPacketIdentifier () const
 
const std::string & getTopic () const
 
const std::string & getMessage () const
 
bool getRetain () const
 
- Public Member Functions inherited from iot::mqtt_fast::ControlPacket
 ControlPacket (uint8_t type, uint8_t reserved=0)
 
 ControlPacket (iot::mqtt_fast::ControlPacketFactory &controlPacketFactory)
 
 ControlPacket (const ControlPacket &)=delete
 
 ControlPacket (ControlPacket &&)=delete
 
ControlPacketoperator= (const ControlPacket &)=delete
 
ControlPacketoperator= (ControlPacket &&)=delete
 
uint8_t getType () const
 
uint8_t getReserved () const
 
uint64_t getRemainingLength () const
 
std::vector< char > getPacket ()
 
bool isError () const
 

Private Attributes

uint16_t packetIdentifier = 0
 
std::string topic
 
std::string message
 
bool dup = false
 
uint8_t qoS = 0
 
bool retain = false
 

Additional Inherited Members

- Protected Member Functions inherited from iot::mqtt_fast::ControlPacket
std::vector< char > & getValue ()
 
uint8_t getInt8 ()
 
uint16_t getInt16 ()
 
uint32_t getInt32 ()
 
uint64_t getInt64 ()
 
uint32_t getIntV ()
 
std::string getString ()
 
std::string getStringRaw ()
 
std::list< uint8_t > getUint8ListRaw ()
 
void putInt8 (uint8_t value)
 
void putInt16 (uint16_t value)
 
void putInt32 (uint32_t value)
 
void putInt64 (uint64_t value)
 
void putIntV (uint32_t value)
 
void putString (const std::string &value)
 
void putStringRaw (const std::string &value)
 
void putUint8ListRaw (const std::list< uint8_t > &value)
 
bool isError ()
 
- Protected Attributes inherited from iot::mqtt_fast::ControlPacket
bool error = false
 

Detailed Description

Definition at line 40 of file Publish.h.

Constructor & Destructor Documentation

◆ Publish() [1/2]

iot::mqtt_fast::packets::Publish::Publish ( uint16_t packetIdentifier,
const std::string & topic,
const std::string & message,
bool dup = false,
uint8_t qoS = 0,
bool retain = false )

Definition at line 30 of file Publish.cpp.

32 static_cast<uint8_t>((dup ? 0x04 : 0x00) | ((qoS << 1) & 0x06) | (retain ? 0x01 : 0x00)))
34 , topic(topic)
36 , dup(dup)
37 , qoS(qoS)
38 , retain(retain) {
39 // V-Header
40 putString(this->topic);
41
42 if (this->qoS > 0) {
43 putInt16(this->packetIdentifier);
44 }
45
46 // Payload
47 putStringRaw(this->message);
48 }
#define MQTT_PUBLISH
Definition Publish.h:36

References iot::mqtt_fast::ControlPacket::ControlPacket(), dup, message, packetIdentifier, iot::mqtt_fast::ControlPacket::putInt16(), iot::mqtt_fast::ControlPacket::putString(), iot::mqtt_fast::ControlPacket::putStringRaw(), qoS, retain, and topic.

Here is the call graph for this function:

◆ Publish() [2/2]

iot::mqtt_fast::packets::Publish::Publish ( iot::mqtt_fast::ControlPacketFactory & controlPacketFactory)
explicit

Definition at line 50 of file Publish.cpp.

51 : iot::mqtt_fast::ControlPacket(controlPacketFactory) {
52 dup = (controlPacketFactory.getPacketFlags() & 0x08) != 0;
53 qoS = static_cast<uint8_t>((controlPacketFactory.getPacketFlags() & 0x06) >> 1);
54 retain = (controlPacketFactory.getPacketFlags() & 0x01) != 0;
55
56 // V-Header
57 topic = getString();
58
59 if (qoS != 0) {
61 }
62
63 // Payload
65
66 error = isError();
67 }

References iot::mqtt_fast::ControlPacket::ControlPacket(), dup, iot::mqtt_fast::ControlPacket::error, iot::mqtt_fast::ControlPacket::getInt16(), iot::mqtt_fast::ControlPacketFactory::getPacketFlags(), iot::mqtt_fast::ControlPacket::getString(), iot::mqtt_fast::ControlPacket::getStringRaw(), message, packetIdentifier, qoS, retain, and topic.

Here is the call graph for this function:

Member Function Documentation

◆ getDup()

bool iot::mqtt_fast::packets::Publish::getDup ( ) const

Definition at line 69 of file Publish.cpp.

69 {
70 return dup;
71 }

References dup.

◆ getMessage()

const std::string & iot::mqtt_fast::packets::Publish::getMessage ( ) const

Definition at line 85 of file Publish.cpp.

85 {
86 return message;
87 }

References message.

◆ getPacketIdentifier()

uint16_t iot::mqtt_fast::packets::Publish::getPacketIdentifier ( ) const

Definition at line 77 of file Publish.cpp.

77 {
78 return packetIdentifier;
79 }

References packetIdentifier.

◆ getQoS()

uint8_t iot::mqtt_fast::packets::Publish::getQoS ( ) const

Definition at line 73 of file Publish.cpp.

73 {
74 return qoS;
75 }

References qoS.

◆ getRetain()

bool iot::mqtt_fast::packets::Publish::getRetain ( ) const

Definition at line 89 of file Publish.cpp.

89 {
90 return retain;
91 }

References retain.

◆ getTopic()

const std::string & iot::mqtt_fast::packets::Publish::getTopic ( ) const

Definition at line 81 of file Publish.cpp.

81 {
82 return topic;
83 }

References topic.

Member Data Documentation

◆ dup

bool iot::mqtt_fast::packets::Publish::dup = false
private

Definition at line 62 of file Publish.h.

Referenced by getDup(), Publish(), and Publish().

◆ message

std::string iot::mqtt_fast::packets::Publish::message
private

Definition at line 61 of file Publish.h.

Referenced by getMessage(), Publish(), and Publish().

◆ packetIdentifier

uint16_t iot::mqtt_fast::packets::Publish::packetIdentifier = 0
private

Definition at line 59 of file Publish.h.

Referenced by getPacketIdentifier(), Publish(), and Publish().

◆ qoS

uint8_t iot::mqtt_fast::packets::Publish::qoS = 0
private

Definition at line 63 of file Publish.h.

Referenced by getQoS(), Publish(), and Publish().

◆ retain

bool iot::mqtt_fast::packets::Publish::retain = false
private

Definition at line 64 of file Publish.h.

Referenced by getRetain(), Publish(), and Publish().

◆ topic

std::string iot::mqtt_fast::packets::Publish::topic
private

Definition at line 60 of file Publish.h.

Referenced by getTopic(), Publish(), and Publish().


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