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

#include <Connect.h>

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

Public Member Functions

 Connect (const std::string &clientId, const std::string &protocol="MQTT", uint8_t version=4, uint8_t flags=0, uint16_t keepAlive=0x003C)
 
 Connect (iot::mqtt_fast::ControlPacketFactory &controlPacketFactory)
 
std::string getProtocol () const
 
uint8_t getLevel () const
 
uint8_t getFlags () const
 
uint16_t getKeepAlive () const
 
const std::string & getClientId () const
 
bool getUsernameFlag () const
 
bool getPasswordFlag () const
 
bool getWillRetain () const
 
uint8_t getWillQoS () const
 
bool getWillFlag () const
 
bool getCleanSession () const
 
const std::string & getWillTopic () const
 
const std::string & getWillMessage () const
 
const std::string & getUsername () const
 
const std::string & getPassword () 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

std::string protocol
 
uint8_t level = 0
 
uint8_t flags = 0
 
uint16_t keepAlive = 0
 
std::string clientId
 
std::string willTopic
 
std::string willMessage
 
std::string username
 
std::string password
 
bool usernameFlag = false
 
bool passwordFlag = false
 
bool willRetain = false
 
uint8_t willQoS = 0
 
bool willFlag = false
 
bool cleanSession = false
 
bool reserved = 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 64 of file Connect.h.

Constructor & Destructor Documentation

◆ Connect() [1/2]

iot::mqtt_fast::packets::Connect::Connect ( const std::string &  clientId,
const std::string &  protocol = "MQTT",
uint8_t  version = 4,
uint8_t  flags = 0,
uint16_t  keepAlive = 0x003C 
)
explicit

Definition at line 50 of file Connect.cpp.

53 , level(version)
54 , flags(flags)
57 // V-Header
58 putString(this->protocol);
59 putInt8(this->level);
60 putInt8(this->flags);
61 putInt16(this->keepAlive);
62
63 // Payload
64 putString(this->clientId);
65 }
void putInt16(uint16_t value)
void putString(const std::string &value)
#define MQTT_CONNECT
Definition Connect.h:58

References clientId, iot::mqtt_fast::ControlPacket::ControlPacket(), flags, keepAlive, level, protocol, iot::mqtt_fast::ControlPacket::putInt16(), iot::mqtt_fast::ControlPacket::putInt8(), and iot::mqtt_fast::ControlPacket::putString().

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

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

◆ Connect() [2/2]

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

Definition at line 67 of file Connect.cpp.

68 : iot::mqtt_fast::ControlPacket(controlPacketFactory) {
69 // V-Header
71 level = getInt8();
72 flags = getInt8();
74
75 usernameFlag = (flags & 0x80) != 0;
76 passwordFlag = (flags & 0x40) != 0;
77 willRetain = (flags & 0x20) != 0;
78 willQoS = (flags & 0x18) >> 3;
79 willFlag = (flags & 0x04) != 0;
80 cleanSession = (flags & 0x02) != 0;
81 reserved = (flags & 0x01) != 0;
82
83 // Payload
84 if (!isError()) {
86 } else {
87 error = true;
88 }
89
90 if (!error && willFlag) {
93 }
94
95 if (!error && usernameFlag) {
97 }
98
99 if (!error && passwordFlag) {
101 }
102 }

References cleanSession, clientId, iot::mqtt_fast::ControlPacket::ControlPacket(), iot::mqtt_fast::ControlPacket::error, flags, iot::mqtt_fast::ControlPacket::getInt16(), iot::mqtt_fast::ControlPacket::getInt8(), iot::mqtt_fast::ControlPacket::getString(), iot::mqtt_fast::ControlPacket::isError(), keepAlive, level, password, passwordFlag, protocol, reserved, username, usernameFlag, willFlag, willMessage, willQoS, willRetain, and willTopic.

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

◆ getCleanSession()

bool iot::mqtt_fast::packets::Connect::getCleanSession ( ) const

Definition at line 144 of file Connect.cpp.

144 {
145 return cleanSession;
146 }

References cleanSession.

◆ getClientId()

const std::string & iot::mqtt_fast::packets::Connect::getClientId ( ) const

Definition at line 120 of file Connect.cpp.

120 {
121 return clientId;
122 }

References clientId.

◆ getFlags()

uint8_t iot::mqtt_fast::packets::Connect::getFlags ( ) const

Definition at line 112 of file Connect.cpp.

112 {
113 return flags;
114 }

References flags.

◆ getKeepAlive()

uint16_t iot::mqtt_fast::packets::Connect::getKeepAlive ( ) const

Definition at line 116 of file Connect.cpp.

116 {
117 return keepAlive;
118 }

References keepAlive.

◆ getLevel()

uint8_t iot::mqtt_fast::packets::Connect::getLevel ( ) const

Definition at line 108 of file Connect.cpp.

108 {
109 return level;
110 }

References level.

◆ getPassword()

const std::string & iot::mqtt_fast::packets::Connect::getPassword ( ) const

Definition at line 160 of file Connect.cpp.

160 {
161 return password;
162 }

References password.

◆ getPasswordFlag()

bool iot::mqtt_fast::packets::Connect::getPasswordFlag ( ) const

Definition at line 128 of file Connect.cpp.

128 {
129 return passwordFlag;
130 }

References passwordFlag.

◆ getProtocol()

std::string iot::mqtt_fast::packets::Connect::getProtocol ( ) const

Definition at line 104 of file Connect.cpp.

104 {
105 return protocol;
106 }

References protocol.

◆ getUsername()

const std::string & iot::mqtt_fast::packets::Connect::getUsername ( ) const

Definition at line 156 of file Connect.cpp.

156 {
157 return username;
158 }

References username.

◆ getUsernameFlag()

bool iot::mqtt_fast::packets::Connect::getUsernameFlag ( ) const

Definition at line 124 of file Connect.cpp.

124 {
125 return usernameFlag;
126 }

References usernameFlag.

◆ getWillFlag()

bool iot::mqtt_fast::packets::Connect::getWillFlag ( ) const

Definition at line 140 of file Connect.cpp.

140 {
141 return willFlag;
142 }

References willFlag.

◆ getWillMessage()

const std::string & iot::mqtt_fast::packets::Connect::getWillMessage ( ) const

Definition at line 152 of file Connect.cpp.

152 {
153 return willMessage;
154 }

References willMessage.

◆ getWillQoS()

uint8_t iot::mqtt_fast::packets::Connect::getWillQoS ( ) const

Definition at line 136 of file Connect.cpp.

136 {
137 return willQoS;
138 }

References willQoS.

◆ getWillRetain()

bool iot::mqtt_fast::packets::Connect::getWillRetain ( ) const

Definition at line 132 of file Connect.cpp.

132 {
133 return willRetain;
134 }

References willRetain.

◆ getWillTopic()

const std::string & iot::mqtt_fast::packets::Connect::getWillTopic ( ) const

Definition at line 148 of file Connect.cpp.

148 {
149 return willTopic;
150 }

References willTopic.

Member Data Documentation

◆ cleanSession

bool iot::mqtt_fast::packets::Connect::cleanSession = false
private

Definition at line 109 of file Connect.h.

Referenced by Connect(), and getCleanSession().

◆ clientId

std::string iot::mqtt_fast::packets::Connect::clientId
private

Definition at line 98 of file Connect.h.

Referenced by Connect(), Connect(), and getClientId().

◆ flags

uint8_t iot::mqtt_fast::packets::Connect::flags = 0
private

Definition at line 95 of file Connect.h.

Referenced by Connect(), Connect(), and getFlags().

◆ keepAlive

uint16_t iot::mqtt_fast::packets::Connect::keepAlive = 0
private

Definition at line 96 of file Connect.h.

Referenced by Connect(), Connect(), and getKeepAlive().

◆ level

uint8_t iot::mqtt_fast::packets::Connect::level = 0
private

Definition at line 94 of file Connect.h.

Referenced by Connect(), Connect(), and getLevel().

◆ password

std::string iot::mqtt_fast::packets::Connect::password
private

Definition at line 102 of file Connect.h.

Referenced by Connect(), and getPassword().

◆ passwordFlag

bool iot::mqtt_fast::packets::Connect::passwordFlag = false
private

Definition at line 105 of file Connect.h.

Referenced by Connect(), and getPasswordFlag().

◆ protocol

std::string iot::mqtt_fast::packets::Connect::protocol
private

Definition at line 93 of file Connect.h.

Referenced by Connect(), Connect(), and getProtocol().

◆ reserved

bool iot::mqtt_fast::packets::Connect::reserved = false
private

Definition at line 110 of file Connect.h.

Referenced by Connect().

◆ username

std::string iot::mqtt_fast::packets::Connect::username
private

Definition at line 101 of file Connect.h.

Referenced by Connect(), and getUsername().

◆ usernameFlag

bool iot::mqtt_fast::packets::Connect::usernameFlag = false
private

Definition at line 104 of file Connect.h.

Referenced by Connect(), and getUsernameFlag().

◆ willFlag

bool iot::mqtt_fast::packets::Connect::willFlag = false
private

Definition at line 108 of file Connect.h.

Referenced by Connect(), and getWillFlag().

◆ willMessage

std::string iot::mqtt_fast::packets::Connect::willMessage
private

Definition at line 100 of file Connect.h.

Referenced by Connect(), and getWillMessage().

◆ willQoS

uint8_t iot::mqtt_fast::packets::Connect::willQoS = 0
private

Definition at line 107 of file Connect.h.

Referenced by Connect(), and getWillQoS().

◆ willRetain

bool iot::mqtt_fast::packets::Connect::willRetain = false
private

Definition at line 106 of file Connect.h.

Referenced by Connect(), and getWillRetain().

◆ willTopic

std::string iot::mqtt_fast::packets::Connect::willTopic
private

Definition at line 99 of file Connect.h.

Referenced by Connect(), and getWillTopic().


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