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 62 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 52 of file Publish.cpp.

54 static_cast<uint8_t>((dup ? 0x04 : 0x00) | ((qoS << 1) & 0x06) | (retain ? 0x01 : 0x00)))
56 , topic(topic)
58 , dup(dup)
59 , qoS(qoS)
60 , retain(retain) {
61 // V-Header
62 putString(this->topic);
63
64 if (this->qoS > 0) {
65 putInt16(this->packetIdentifier);
66 }
67
68 // Payload
69 putStringRaw(this->message);
70 }
#define MQTT_PUBLISH
Definition Publish.h:58

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.

Referenced by iot::mqtt_fast::SocketContext::sendPublish().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Publish() [2/2]

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

Definition at line 72 of file Publish.cpp.

73 : iot::mqtt_fast::ControlPacket(controlPacketFactory) {
74 dup = (controlPacketFactory.getPacketFlags() & 0x08) != 0;
75 qoS = static_cast<uint8_t>((controlPacketFactory.getPacketFlags() & 0x06) >> 1);
76 retain = (controlPacketFactory.getPacketFlags() & 0x01) != 0;
77
78 // V-Header
79 topic = getString();
80
81 if (qoS != 0) {
83 }
84
85 // Payload
87
88 error = isError();
89 }

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(), iot::mqtt_fast::ControlPacket::isError(), message, packetIdentifier, qoS, retain, and topic.

Referenced by iot::mqtt_fast::SocketContext::onReceivedFromPeer().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Function Documentation

◆ getDup()

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

Definition at line 91 of file Publish.cpp.

91 {
92 return dup;
93 }

References dup.

◆ getMessage()

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

Definition at line 107 of file Publish.cpp.

107 {
108 return message;
109 }

References message.

◆ getPacketIdentifier()

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

Definition at line 99 of file Publish.cpp.

99 {
100 return packetIdentifier;
101 }

References packetIdentifier.

◆ getQoS()

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

Definition at line 95 of file Publish.cpp.

95 {
96 return qoS;
97 }

References qoS.

◆ getRetain()

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

Definition at line 111 of file Publish.cpp.

111 {
112 return retain;
113 }

References retain.

◆ getTopic()

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

Definition at line 103 of file Publish.cpp.

103 {
104 return topic;
105 }

References topic.

Member Data Documentation

◆ dup

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

Definition at line 84 of file Publish.h.

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

◆ message

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

Definition at line 83 of file Publish.h.

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

◆ packetIdentifier

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

Definition at line 81 of file Publish.h.

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

◆ qoS

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

Definition at line 85 of file Publish.h.

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

◆ retain

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

Definition at line 86 of file Publish.h.

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

◆ topic

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

Definition at line 82 of file Publish.h.

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


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