acl/lib_acl_cpp/include/acl_cpp/mqtt/mqtt_subscribe.hpp

51 lines
955 B
C++
Raw Normal View History

2021-03-02 18:34:34 +08:00
#pragma once
#include "mqtt_message.hpp"
namespace acl {
class mqtt_subscribe : public mqtt_message {
public:
2021-03-03 16:00:13 +08:00
mqtt_subscribe(unsigned payload_len = 0);
2021-03-02 18:34:34 +08:00
~mqtt_subscribe(void);
void set_pkt_id(unsigned short id);
void add_topic(const char* topic, mqtt_qos_t qos);
unsigned short get_pkt_id(void) const {
return pkt_id_;
}
bool to_string(string& out);
int update(const char* data, int dlen);
2021-03-02 18:34:34 +08:00
2021-03-03 16:00:13 +08:00
public:
int update_header_var(const char* data, int dlen);
int update_topic_len(const char* data, int dlen);
int update_topic_val(const char* data, int dlen);
int update_topic_qos(const char* data, int dlen);
2021-03-03 16:00:13 +08:00
2021-03-02 18:34:34 +08:00
protected:
// @override
unsigned char get_header_flags(void) const {
return 0x02;
}
private:
2021-03-03 16:00:13 +08:00
bool finished_;
char buff_[2];
unsigned dlen_;
2021-03-03 18:36:31 +08:00
2021-03-02 18:34:34 +08:00
unsigned short pkt_id_;
std::vector<string> topics_;
std::vector<mqtt_qos_t> qoses_;
2021-03-03 18:36:31 +08:00
2021-03-02 18:34:34 +08:00
unsigned payload_len_;
2021-03-03 16:00:13 +08:00
unsigned nread_;
string topic_;
2021-03-02 18:34:34 +08:00
};
} // namespace acl