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

#include <Publish.h>

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

Public Member Functions

 Publish ()
 
 Publish (uint16_t packetIdentifier, const std::string &topic, const std::string &message, uint8_t qoS, bool dup, bool retain)
 
bool getDup () const
 
uint8_t getQoS () const
 
uint16_t getPacketIdentifier () const
 
std::string getTopic () const
 
std::string getMessage () const
 
bool getRetain () const
 
- Public Member Functions inherited from iot::mqtt::ControlPacket
 ControlPacket (uint8_t type, const std::string &name)
 
 ControlPacket (const ControlPacket &)=default
 
 ControlPacket (ControlPacket &&)=default
 
virtual ~ControlPacket ()
 
ControlPacketoperator= (const ControlPacket &)=default
 
ControlPacketoperator= (ControlPacket &&)=default
 
std::vector< char > serialize () const
 
const std::string & getName () const
 
uint8_t getType () const
 
uint8_t getFlags () const
 

Protected Attributes

iot::mqtt::types::UInt16 packetIdentifier
 
iot::mqtt::types::String topic
 
iot::mqtt::types::StringRaw message
 
bool dup = false
 
uint8_t qoS = 0
 
bool retain = false
 
- Protected Attributes inherited from iot::mqtt::ControlPacket
uint8_t flags = 0
 

Private Member Functions

std::vector< char > serializeVP () const override
 

Detailed Description

Definition at line 59 of file Publish.h.

Constructor & Destructor Documentation

◆ Publish() [1/2]

iot::mqtt::packets::Publish::Publish ( )

Definition at line 52 of file Publish.cpp.

54 }
#define MQTT_PUBLISH
Definition Publish.h:58

References iot::mqtt::ControlPacket::ControlPacket().

Referenced by Publish().

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

◆ Publish() [2/2]

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

Definition at line 56 of file Publish.cpp.

57 : Publish() {
58 this->flags = static_cast<uint8_t>((dup ? 0x08 : 0x00) | ((qoS << 1) & 0x06) | (retain ? 0x01 : 0x00));
60 this->topic = topic;
61 this->message = message;
62 this->dup = dup;
63 this->qoS = qoS;
64 this->retain = retain;
65 }
iot::mqtt::types::StringRaw message
Definition Publish.h:79
iot::mqtt::types::UInt16 packetIdentifier
Definition Publish.h:77
iot::mqtt::types::String topic
Definition Publish.h:78

References dup, iot::mqtt::ControlPacket::flags, message, iot::mqtt::types::String::operator=(), iot::mqtt::types::StringRaw::operator=(), iot::mqtt::types::UInt16::operator=(), packetIdentifier, Publish(), qoS, retain, and topic.

Referenced by iot::mqtt::Session::fromJson(), and iot::mqtt::Mqtt::sendPublish().

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

Member Function Documentation

◆ getDup()

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

Definition at line 81 of file Publish.cpp.

81 {
82 return dup;
83 }

References dup.

Referenced by iot::mqtt::Mqtt::_onPublish(), and iot::mqtt::Session::toJson().

Here is the caller graph for this function:

◆ getMessage()

std::string iot::mqtt::packets::Publish::getMessage ( ) const

Definition at line 97 of file Publish.cpp.

97 {
98 return message;
99 }

References message.

Referenced by iot::mqtt::Mqtt::_onPublish(), iot::mqtt::server::Mqtt::_onPublish(), and iot::mqtt::Session::toJson().

Here is the caller graph for this function:

◆ getPacketIdentifier()

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

Definition at line 89 of file Publish.cpp.

89 {
90 return packetIdentifier;
91 }

References packetIdentifier.

Referenced by iot::mqtt::Mqtt::_onPublish().

Here is the caller graph for this function:

◆ getQoS()

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

Definition at line 85 of file Publish.cpp.

85 {
86 return qoS;
87 }

References qoS.

Referenced by iot::mqtt::Mqtt::_onPublish(), iot::mqtt::server::Mqtt::_onPublish(), and iot::mqtt::Session::toJson().

Here is the caller graph for this function:

◆ getRetain()

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

Definition at line 101 of file Publish.cpp.

101 {
102 return retain;
103 }

References retain.

Referenced by iot::mqtt::Mqtt::_onPublish(), iot::mqtt::server::Mqtt::_onPublish(), and iot::mqtt::Session::toJson().

Here is the caller graph for this function:

◆ getTopic()

std::string iot::mqtt::packets::Publish::getTopic ( ) const

Definition at line 93 of file Publish.cpp.

93 {
94 return topic;
95 }

References topic.

Referenced by iot::mqtt::Mqtt::_onPublish(), iot::mqtt::server::Mqtt::_onPublish(), and iot::mqtt::Session::toJson().

Here is the caller graph for this function:

◆ serializeVP()

std::vector< char > iot::mqtt::packets::Publish::serializeVP ( ) const
overrideprivatevirtual

Implements iot::mqtt::ControlPacket.

Definition at line 67 of file Publish.cpp.

67 {
68 std::vector<char> packet(topic.serialize());
69
70 if (qoS > 0) {
71 std::vector<char> tmpVector = packetIdentifier.serialize();
72 packet.insert(packet.end(), tmpVector.begin(), tmpVector.end());
73 }
74
75 std::vector<char> tmpVector = message.serialize();
76 packet.insert(packet.end(), tmpVector.begin(), tmpVector.end());
77
78 return packet;
79 }
std::vector< char > serialize() const override
Definition String.cpp:97
virtual std::vector< char > serialize() const
Definition TypeBase.hpp:83

References message, packetIdentifier, qoS, iot::mqtt::types::TypeBase< ValueTypeT >::serialize(), iot::mqtt::types::String::serialize(), and topic.

Here is the call graph for this function:

Member Data Documentation

◆ dup

bool iot::mqtt::packets::Publish::dup = false
protected

◆ message

◆ packetIdentifier

◆ qoS

◆ retain

bool iot::mqtt::packets::Publish::retain = false
protected

◆ topic


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