add pingreq, pingresp and disconnect for mqtt

This commit is contained in:
shuxin   zheng 2021-03-04 17:47:27 +08:00
parent ed9d2fded9
commit 7474b95a83
6 changed files with 126 additions and 0 deletions

View File

@ -0,0 +1,15 @@
#pragma once
#include "mqtt_message.hpp"
namespace acl {
class mqtt_disconnect : public mqtt_message {
public:
mqtt_disconnect(void);
~mqtt_disconnect(void);
bool to_string(string& out);
};
} // namespace acl

View File

@ -0,0 +1,15 @@
#pragma once
#include "mqtt_message.hpp"
namespace acl {
class mqtt_pingreq : public mqtt_message {
public:
mqtt_pingreq(void);
~mqtt_pingreq(void);
bool to_string(string& out);
};
} // namespace acl

View File

@ -0,0 +1,15 @@
#pragma once
#include "mqtt_message.hpp"
namespace acl {
class mqtt_pingresp : public mqtt_message {
public:
mqtt_pingresp(void);
~mqtt_pingresp(void);
bool to_string(string& out);
};
} // namespace acl

View File

@ -0,0 +1,27 @@
#include "acl_stdafx.hpp"
#include "acl_cpp/mqtt/mqtt_disconnect.hpp"
namespace acl {
mqtt_disconnect::mqtt_disconnect()
: mqtt_message(MQTT_DISCONNECT)
{
}
mqtt_disconnect::~mqtt_disconnect(void) {}
bool mqtt_disconnect::to_string(string& out) {
bool old_mode = out.get_bin();
this->set_data_length(0);
if (!this->pack_header(out)) {
out.set_bin(old_mode);
return false;
}
out.set_bin(old_mode);
return true;
}
} // namespace acl

View File

@ -0,0 +1,27 @@
#include "acl_stdafx.hpp"
#include "acl_cpp/mqtt/mqtt_pingreq.hpp"
namespace acl {
mqtt_pingreq::mqtt_pingreq()
: mqtt_message(MQTT_PINGREQ)
{
}
mqtt_pingreq::~mqtt_pingreq(void) {}
bool mqtt_pingreq::to_string(string& out) {
bool old_mode = out.get_bin();
this->set_data_length(0);
if (!this->pack_header(out)) {
out.set_bin(old_mode);
return false;
}
out.set_bin(old_mode);
return true;
}
} // namespace acl

View File

@ -0,0 +1,27 @@
#include "acl_stdafx.hpp"
#include "acl_cpp/mqtt/mqtt_pingresp.hpp"
namespace acl {
mqtt_pingresp::mqtt_pingresp()
: mqtt_message(MQTT_PINGRESP)
{
}
mqtt_pingresp::~mqtt_pingresp(void) {}
bool mqtt_pingresp::to_string(string& out) {
bool old_mode = out.get_bin();
this->set_data_length(0);
if (!this->pack_header(out)) {
out.set_bin(old_mode);
return false;
}
out.set_bin(old_mode);
return true;
}
} // namespace acl