mirror of
https://gitee.com/acl-dev/acl.git
synced 2024-11-30 10:57:34 +08:00
add pingreq, pingresp and disconnect for mqtt
This commit is contained in:
parent
ed9d2fded9
commit
7474b95a83
15
lib_acl_cpp/include/acl_cpp/mqtt/mqtt_disconnect.hpp
Normal file
15
lib_acl_cpp/include/acl_cpp/mqtt/mqtt_disconnect.hpp
Normal 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
|
15
lib_acl_cpp/include/acl_cpp/mqtt/mqtt_pingreq.hpp
Normal file
15
lib_acl_cpp/include/acl_cpp/mqtt/mqtt_pingreq.hpp
Normal 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
|
15
lib_acl_cpp/include/acl_cpp/mqtt/mqtt_pingresp.hpp
Normal file
15
lib_acl_cpp/include/acl_cpp/mqtt/mqtt_pingresp.hpp
Normal 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
|
27
lib_acl_cpp/src/mqtt/mqtt_disconnect.cpp
Normal file
27
lib_acl_cpp/src/mqtt/mqtt_disconnect.cpp
Normal 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
|
27
lib_acl_cpp/src/mqtt/mqtt_pingreq.cpp
Normal file
27
lib_acl_cpp/src/mqtt/mqtt_pingreq.cpp
Normal 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
|
27
lib_acl_cpp/src/mqtt/mqtt_pingresp.cpp
Normal file
27
lib_acl_cpp/src/mqtt/mqtt_pingresp.cpp
Normal 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
|
Loading…
Reference in New Issue
Block a user