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

63 lines
1.2 KiB
C++
Raw Normal View History

2021-03-02 18:34:34 +08:00
#pragma once
#include "mqtt_message.hpp"
namespace acl {
2021-03-07 12:45:22 +08:00
class ACL_CPP_API mqtt_subscribe : public mqtt_message {
2021-03-02 18:34:34 +08:00
public:
2021-03-08 15:03:32 +08:00
mqtt_subscribe(void);
mqtt_subscribe(const mqtt_header& header);
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_;
}
2021-03-06 10:49:22 +08:00
const std::vector<string>& get_topics(void) const {
return topics_;
}
const std::vector<mqtt_qos_t>& get_qoses(void) const {
return qoses_;
}
protected:
// @override
2021-03-02 18:34:34 +08:00
bool to_string(string& out);
// @override
int update(const char* data, int dlen);
2021-03-02 18:34:34 +08:00
// @override
bool is_finished(void) const {
return finished_;
}
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
private:
2021-03-08 15:03:32 +08:00
unsigned status_;
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
unsigned body_len_;
2021-03-03 16:00:13 +08:00
unsigned nread_;
string topic_;
2021-03-02 18:34:34 +08:00
};
} // namespace acl