acl  3.5.3.0
mqtt_ack.hpp
浏览该文件的文档.
1 #pragma once
2 
3 #include "mqtt_message.hpp"
4 
5 namespace acl {
6 
7 /**
8  * the base class for acking some mqtt message, used by some mqtt message type.
9  */
11 public:
12  /**
13  * usually used when build a ack mqtt message.
14  * @param type {mqtt_type_t}
15  */
16  mqtt_ack(mqtt_type_t type);
17 
18  /**
19  * usually used when parsing a ack mqtt messsage.
20  * @param header {const mqtt_header&} will be copied internal.
21  */
22  mqtt_ack(const mqtt_header& header);
23 
24  virtual ~mqtt_ack(void);
25 
26  /**
27  * set the mqtt message's id.
28  * @param id {unsigned short} should > 0 && <= 65535.
29  */
30  void set_pkt_id(unsigned short id);
31 
32  /**
33  * get the mqtt message's id
34  * @return {unsigned short} if some error happened, 0 will be returned.
35  */
36  unsigned short get_pkt_id(void) const {
37  return pkt_id_;
38  }
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  // for parsing message header in streaming mode.
54  int update_header_var(const char* data, int dlen);
55 
56 private:
57  unsigned status_;
58  bool finished_;
59  char hbuf_[2];
60  unsigned hlen_;
61 
62  unsigned short pkt_id_;
63 };
64 
65 } // namespace acl
bool finished(void) const
Definition: mqtt_ack.hpp:48
mqtt_type_t
Definition: mqtt_header.hpp:10
unsigned short get_pkt_id(void) const
Definition: mqtt_ack.hpp:36
#define ACL_CPP_API