2021-03-04 16:59:00 +08:00
|
|
|
#pragma once
|
|
|
|
|
2021-03-06 10:49:22 +08:00
|
|
|
#include <vector>
|
2021-03-04 16:59:00 +08:00
|
|
|
#include "mqtt_message.hpp"
|
|
|
|
|
|
|
|
namespace acl {
|
|
|
|
|
2021-03-07 12:45:22 +08:00
|
|
|
class ACL_CPP_API mqtt_suback : public mqtt_message {
|
2021-03-04 16:59:00 +08:00
|
|
|
public:
|
2021-03-08 15:03:32 +08:00
|
|
|
mqtt_suback(void);
|
|
|
|
mqtt_suback(const mqtt_header& header);
|
2021-03-04 16:59:00 +08:00
|
|
|
~mqtt_suback(void);
|
|
|
|
|
2021-03-11 19:03:22 +08:00
|
|
|
mqtt_suback& set_pkt_id(unsigned short id);
|
|
|
|
mqtt_suback& add_topic_qos(mqtt_qos_t qos);
|
|
|
|
mqtt_suback& add_topic_qos(const std::vector<mqtt_qos_t>& qoses);
|
2021-03-04 16:59:00 +08:00
|
|
|
|
2021-03-06 10:49:22 +08:00
|
|
|
unsigned short get_pkt_id(void) const {
|
|
|
|
return pkt_id_;
|
|
|
|
}
|
|
|
|
|
|
|
|
const std::vector<mqtt_qos_t>& get_qoses(void) const {
|
|
|
|
return qoses_;
|
|
|
|
}
|
|
|
|
|
2021-03-05 14:30:21 +08:00
|
|
|
protected:
|
|
|
|
// @override
|
2021-03-04 16:59:00 +08:00
|
|
|
bool to_string(string& out);
|
|
|
|
|
2021-03-05 14:30:21 +08:00
|
|
|
// @override
|
2021-03-04 16:59:00 +08:00
|
|
|
int update(const char* data, int dlen);
|
|
|
|
|
2021-03-05 14:30:21 +08:00
|
|
|
// @override
|
2021-03-10 17:21:29 +08:00
|
|
|
bool finished(void) const {
|
2021-03-05 14:30:21 +08:00
|
|
|
return finished_;
|
|
|
|
}
|
|
|
|
|
2021-03-04 16:59:00 +08:00
|
|
|
public:
|
|
|
|
int update_header_var(const char* data, int dlen);
|
|
|
|
int update_topic_qos(const char* data, int dlen);
|
|
|
|
|
|
|
|
private:
|
2021-03-08 15:03:32 +08:00
|
|
|
unsigned status_;
|
2021-03-04 16:59:00 +08:00
|
|
|
bool finished_;
|
|
|
|
char buff_[2];
|
|
|
|
unsigned dlen_;
|
|
|
|
|
|
|
|
unsigned short pkt_id_;
|
|
|
|
std::vector<mqtt_qos_t> qoses_;
|
|
|
|
|
2021-03-05 14:30:21 +08:00
|
|
|
unsigned body_len_;
|
2021-03-04 16:59:00 +08:00
|
|
|
unsigned nread_;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace acl
|