-
Notifications
You must be signed in to change notification settings - Fork 952
Expand file tree
/
Copy pathmqtt_suback.hpp
More file actions
95 lines (76 loc) · 1.76 KB
/
mqtt_suback.hpp
File metadata and controls
95 lines (76 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#pragma once
#include <vector>
#include "mqtt_message.hpp"
namespace acl {
/**
* mqtt message object for MQTT_SUBACK type.
*/
class ACL_CPP_API mqtt_suback : public mqtt_message {
public:
/**
* constructor for creating MQTT_SUBACK mqtt message object.
* @see mqtt_ack
*/
mqtt_suback();
/**
* constructor for creating MQTT_SUBACK mqtt message object.
* @see mqtt_ack
*/
mqtt_suback(const mqtt_header& header);
~mqtt_suback();
/**
* set the messsage's id.
* @param id {unsigned short} should > 0 && <= 65535.
* @return {mqtt_suback&}
*/
mqtt_suback& set_pkt_id(unsigned short id);
/**
* add the topic's qos.
* @param qos {mqtt_qos_t}
* @return {mqtt_suback&}
*/
mqtt_suback& add_topic_qos(mqtt_qos_t qos);
/**
* add some qoses of topics.
* @param qoses {const std::vector<mqtt_qos_t>&}
* @return {mqtt_suback&}
*/
mqtt_suback& add_topic_qos(const std::vector<mqtt_qos_t>& qoses);
/**
* get the messsage's id.
* @return {unsigned short} some error happened if return 0.
*/
unsigned short get_pkt_id() const {
return pkt_id_;
}
/**
* get all qoses of the topics.
* @return {const std::vector<mqtt_qos_t>&}
*/
const std::vector<mqtt_qos_t>& get_qoses() const {
return qoses_;
}
protected:
// @override
bool to_string(string& out);
// @override
int update(const char* data, int dlen);
// @override
bool finished() const {
return finished_;
}
public:
// use internal to parse suback message in streaming mode.
int update_header_var(const char* data, int dlen);
int update_topic_qos(const char* data, int dlen);
private:
unsigned short pkt_id_;
char buff_[2];
unsigned dlen_;
unsigned status_;
std::vector<mqtt_qos_t> qoses_;
unsigned body_len_;
unsigned nread_;
bool finished_;
};
} // namespace acl