-
Notifications
You must be signed in to change notification settings - Fork 952
Expand file tree
/
Copy pathmqtt_unsubscribe.hpp
More file actions
91 lines (71 loc) · 1.71 KB
/
mqtt_unsubscribe.hpp
File metadata and controls
91 lines (71 loc) · 1.71 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
#pragma once
#include "mqtt_message.hpp"
namespace acl {
/**
* mqtt message object for MQTT_UNSUBSCRIBE type.
*/
class ACL_CPP_API mqtt_unsubscribe : public mqtt_message {
public:
/**
* constructor for creating MQTT_PUBACK mqtt message object.
* @see mqtt_message
*/
mqtt_unsubscribe();
/**
* constructor for creating MQTT_PUBACK mqtt message object.
* @see mqtt_message
*/
mqtt_unsubscribe(const mqtt_header& header);
~mqtt_unsubscribe();
/**
* set the message id.
* @param id {unsigned short} should > 0 && <= 65535.
* @return {mqtt_unsubscribe&}
*/
mqtt_unsubscribe& set_pkt_id(unsigned short id);
/**
* get the messsage's id.
* @return {unsigned short} should return the value that > 0 && <= 65535.
*/
unsigned short get_pkt_id() const {
return pkt_id_;
}
/**
* set the message's topic.
* @param topic {const char*}
* @return {mqtt_unsubscribe&}
*/
mqtt_unsubscribe& add_topic(const char* topic);
/**
* get all the topics.
* @return {const std::vector<std::string>&}
*/
const std::vector<std::string>& get_topics() const {
return topics_;
}
protected:
// @override
bool to_string(string& out);
// @override
int update(const char* data, int dlen);
// @override
bool finished() const {
return finished_;
}
public:
// used internal to parse unsubscribe message in streaming mode.
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);
private:
unsigned short pkt_id_;
char buff_[2];
unsigned dlen_;
unsigned status_;
std::vector<std::string> topics_;
unsigned body_len_;
unsigned nread_;
std::string topic_;
bool finished_;
};
} // namespace acl