SNode.C
Loading...
Searching...
No Matches
iot::mqtt::ControlPacket Class Referenceabstract

#include <ControlPacket.h>

Inheritance diagram for iot::mqtt::ControlPacket:
Collaboration diagram for iot::mqtt::ControlPacket:

Public Member Functions

 ControlPacket (uint8_t type, const std::string &name)
 
 ControlPacket (const ControlPacket &)=default
 
 ControlPacket (ControlPacket &&)=default
 
virtual ~ControlPacket ()
 
ControlPacketoperator= (const ControlPacket &)=default
 
ControlPacketoperator= (ControlPacket &&)=default
 
virtual std::vector< char > serializeVP () const =0
 
std::vector< char > serialize () const
 
const std::string & getName () const
 
uint8_t getType () const
 
uint8_t getFlags () const
 

Protected Attributes

uint8_t flags = 0
 

Private Attributes

std::string name
 
uint8_t type = 0
 

Detailed Description

Definition at line 69 of file ControlPacket.h.

Constructor & Destructor Documentation

◆ ControlPacket() [1/3]

iot::mqtt::ControlPacket::ControlPacket ( uint8_t type,
const std::string & name )

Definition at line 48 of file ControlPacket.cpp.

49 : name(name)
50 , type(type) {
51 switch (type) {
52 case MQTT_CONNECT:
54 break;
55 case MQTT_CONNACK:
57 break;
58 case MQTT_PUBLISH:
59 // no flags for MQTT_PUBLISH_FLAGS
60 break;
61 case MQTT_PUBACK:
63 break;
64 case MQTT_PUBREC:
66 break;
67 case MQTT_PUBREL:
69 break;
70 case MQTT_PUBCOMP:
72 break;
73 case MQTT_SUBSCRIBE:
75 break;
76 case MQTT_SUBACK:
78 break;
81 break;
82 case MQTT_UNSUBACK:
84 break;
85 case MQTT_PINGREQ:
87 break;
88 case MQTT_PINGRESP:
90 break;
91 case MQTT_DISCONNECT:
93 break;
94 }
95 }
#define MQTT_CONNACK
Definition Connack.h:35
#define MQTT_CONNECT
Definition Connect.h:36
#define MQTT_DISCONNECT
Definition Disconnect.h:33
#define MQTT_PINGREQ
Definition Pingreq.h:33
#define MQTT_PINGRESP
Definition Pingresp.h:33
#define MQTT_PUBACK
Definition Puback.h:35
#define MQTT_PUBCOMP
Definition Pubcomp.h:35
#define MQTT_PUBLISH
Definition Publish.h:36
#define MQTT_PUBREC
Definition Pubrec.h:35
#define MQTT_PUBREL
Definition Pubrel.h:35
#define MQTT_SUBACK
Definition Suback.h:36
#define MQTT_SUBSCRIBE
Definition Subscribe.h:37
#define MQTT_UNSUBACK
Definition Unsuback.h:35
#define MQTT_UNSUBSCRIBE
Definition Unsubscribe.h:37
#define MQTT_CONNECT_FLAGS
#define MQTT_PUBREL_FLAGS
#define MQTT_PUBCOMP_FLAGS
#define MQTT_SUBSCRIBE_FLAGS
#define MQTT_SUBACK_FLAGS
#define MQTT_DISCONNECT_FLAGS
#define MQTT_PUBACK_FLAGS
#define MQTT_UNSUBSCRIBE_FLAGS
#define MQTT_CONNACK_FLAGS
#define MQTT_PINGREQ_FLAGS
#define MQTT_PUBREC_FLAGS
#define MQTT_UNSUBACK_FLAGS
#define MQTT_PINGRESP_FLAGS

References ControlPacket(), flags, and type.

Referenced by ControlPacket().

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

◆ ControlPacket() [2/3]

iot::mqtt::ControlPacket::ControlPacket ( const ControlPacket & )
default

◆ ControlPacket() [3/3]

iot::mqtt::ControlPacket::ControlPacket ( ControlPacket && )
default

◆ ~ControlPacket()

iot::mqtt::ControlPacket::~ControlPacket ( )
virtual

Definition at line 97 of file ControlPacket.cpp.

97 {
98 }

Member Function Documentation

◆ getFlags()

uint8_t iot::mqtt::ControlPacket::getFlags ( ) const

Definition at line 119 of file ControlPacket.cpp.

119 {
120 return flags;
121 }

References flags.

◆ getName()

const std::string & iot::mqtt::ControlPacket::getName ( ) const

Definition at line 100 of file ControlPacket.cpp.

100 {
101 return name;
102 }

◆ getType()

uint8_t iot::mqtt::ControlPacket::getType ( ) const

Definition at line 115 of file ControlPacket.cpp.

115 {
116 return type;
117 }

References type.

◆ operator=() [1/2]

ControlPacket & iot::mqtt::ControlPacket::operator= ( const ControlPacket & )
default

◆ operator=() [2/2]

ControlPacket & iot::mqtt::ControlPacket::operator= ( ControlPacket && )
default

◆ serialize()

std::vector< char > iot::mqtt::ControlPacket::serialize ( ) const

Definition at line 104 of file ControlPacket.cpp.

104 {
105 std::vector<char> variablHeaderPayload = serializeVP();
106
107 const FixedHeader fixedHeader(type, flags, static_cast<uint32_t>(variablHeaderPayload.size()));
108
109 std::vector<char> packet = fixedHeader.serialize();
110 packet.insert(packet.end(), variablHeaderPayload.begin(), variablHeaderPayload.end());
111
112 return packet;
113 }
virtual std::vector< char > serializeVP() const =0

◆ serializeVP()

Member Data Documentation

◆ flags

uint8_t iot::mqtt::ControlPacket::flags = 0
protected

Definition at line 92 of file ControlPacket.h.

Referenced by ControlPacket(), getFlags(), and iot::mqtt::packets::Publish::Publish().

◆ name

std::string iot::mqtt::ControlPacket::name
private

Definition at line 88 of file ControlPacket.h.

◆ type

uint8_t iot::mqtt::ControlPacket::type = 0
private

Definition at line 89 of file ControlPacket.h.

Referenced by ControlPacket(), and getType().


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