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 37 of file Publish.h.

Constructor & Destructor Documentation

◆ Publish() [1/2]

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

Definition at line 30 of file Publish.cpp.

32 }
#define MQTT_PUBLISH
Definition Publish.h:36

References Publish().

Referenced by Publish(), and 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 34 of file Publish.cpp.

35 : Publish() {
36 this->flags = static_cast<uint8_t>((dup ? 0x08 : 0x00) | ((qoS << 1) & 0x06) | (retain ? 0x01 : 0x00));
38 this->topic = topic;
39 this->message = message;
40 this->dup = dup;
41 this->qoS = qoS;
42 this->retain = retain;
43 }
iot::mqtt::types::StringRaw message
Definition Publish.h:57
iot::mqtt::types::UInt16 packetIdentifier
Definition Publish.h:55
iot::mqtt::types::String topic
Definition Publish.h:56

References dup, iot::mqtt::ControlPacket::flags, Publish(), qoS, and retain.

Here is the call graph for this function:

Member Function Documentation

◆ getDup()

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

Definition at line 59 of file Publish.cpp.

59 {
60 return dup;
61 }

References dup.

◆ getMessage()

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

Definition at line 75 of file Publish.cpp.

75 {
76 return message;
77 }

◆ getPacketIdentifier()

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

Definition at line 67 of file Publish.cpp.

67 {
68 return packetIdentifier;
69 }

◆ getQoS()

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

Definition at line 63 of file Publish.cpp.

63 {
64 return qoS;
65 }

References qoS.

◆ getRetain()

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

Definition at line 79 of file Publish.cpp.

79 {
80 return retain;
81 }

References retain.

◆ getTopic()

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

Definition at line 71 of file Publish.cpp.

71 {
72 return topic;
73 }

◆ serializeVP()

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

Implements iot::mqtt::ControlPacket.

Definition at line 45 of file Publish.cpp.

45 {
46 std::vector<char> packet(topic.serialize());
47
48 if (qoS > 0) {
49 std::vector<char> tmpVector = packetIdentifier.serialize();
50 packet.insert(packet.end(), tmpVector.begin(), tmpVector.end());
51 }
52
53 std::vector<char> tmpVector = message.serialize();
54 packet.insert(packet.end(), tmpVector.begin(), tmpVector.end());
55
56 return packet;
57 }
std::vector< char > serialize() const override
Definition String.cpp:75
virtual std::vector< char > serialize() const
Definition TypeBase.hpp:61

References qoS.

Member Data Documentation

◆ dup

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

Definition at line 59 of file Publish.h.

Referenced by getDup(), and Publish().

◆ message

iot::mqtt::types::StringRaw iot::mqtt::packets::Publish::message
protected

Definition at line 57 of file Publish.h.

◆ packetIdentifier

iot::mqtt::types::UInt16 iot::mqtt::packets::Publish::packetIdentifier
protected

Definition at line 55 of file Publish.h.

◆ qoS

uint8_t iot::mqtt::packets::Publish::qoS = 0
protected

Definition at line 60 of file Publish.h.

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

◆ retain

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

Definition at line 61 of file Publish.h.

Referenced by getRetain(), and Publish().

◆ topic

iot::mqtt::types::String iot::mqtt::packets::Publish::topic
protected

Definition at line 56 of file Publish.h.


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