acl  3.5.3.0
mqtt_unsubscribe.hpp
浏览该文件的文档.
1 #pragma once
2 
3 #include "mqtt_message.hpp"
4 
5 namespace acl {
6 
7 /**
8  * mqtt message object for MQTT_UNSUBSCRIBE type.
9  */
11 public:
12  /**
13  * constructor for creating MQTT_PUBACK mqtt message object.
14  * @see mqtt_message
15  */
16  mqtt_unsubscribe(void);
17 
18  /**
19  * constructor for creating MQTT_PUBACK mqtt message object.
20  * @see mqtt_message
21  */
22  mqtt_unsubscribe(const mqtt_header& header);
23 
24  ~mqtt_unsubscribe(void);
25 
26  /**
27  * set the message id.
28  * @param id {unsigned short} should > 0 && <= 65535.
29  * @return {mqtt_unsubscribe&}
30  */
31  mqtt_unsubscribe& set_pkt_id(unsigned short id);
32 
33  /**
34  * set the message's topic.
35  * @param topic {const char*}
36  * @return {mqtt_unsubscribe&}
37  */
38  mqtt_unsubscribe& add_topic(const char* topic);
39 
40 protected:
41  // @override
42  bool to_string(string& out);
43 
44  // @override
45  int update(const char* data, int dlen);
46 
47  // @override
48  bool finished(void) const {
49  return finished_;
50  }
51 
52 public:
53  // used internal to parse unsubscribe message in streaming mode.
54 
55  int update_header_var(const char* data, int dlen);
56  int update_topic_len(const char* data, int dlen);
57  int update_topic_val(const char* data, int dlen);
58 
59 private:
60  unsigned status_;
61  bool finished_;
62  char buff_[2];
63  unsigned dlen_;
64 
65  unsigned short pkt_id_;
66  std::vector<string> topics_;
67 
68  unsigned body_len_;
69  unsigned nread_;
70 
71  string topic_;
72 };
73 
74 } // namespace acl
75 
bool finished(void) const
#define ACL_CPP_API