acl  3.5.3.0
mqtt_connack.hpp
浏览该文件的文档.
1 #pragma once
2 
3 #include "mqtt_message.hpp"
4 
5 namespace acl {
6 
7 /**
8  * the status of connection.
9  */
10 enum {
17 };
18 
19 /**
20  * mqtt message object for the MQTT_CONNACK type.
21  */
23 public:
24  /**
25  * constructor for creating MQTT_CONNACK mqtt message object.
26  * @see mqtt_message
27  */
28  mqtt_connack(void);
29 
30  /**
31  * constructor for creating MQTT_CONNACK mqtt message object.
32  * @see mqtt_message
33  */
34  mqtt_connack(const mqtt_header& header);
35 
36  ~mqtt_connack(void);
37 
38  /**
39  * set the session control for the connection
40  * @param on {bool}
41  * @return {mqtt_connack&}
42  */
43  mqtt_connack& set_session(bool on);
44 
45  /**
46  * set the connect return code
47  * @param code {unsigned char} defined as MQTT_CONNACK_XXX above.
48  * @return {mqtt_connack&}
49  */
50  mqtt_connack& set_connack_code(unsigned char code);
51 
52  /**
53  * get the session control status
54  * @return {bool}
55  */
56  bool get_session(void) const {
57  return session_;
58  }
59 
60  /**
61  * get the connect resturn code
62  * @return {unsigned char} defined as MQTT_CONNACK_XXX above.
63  */
64  unsigned char get_connack_code(void) const {
65  return connack_code_;
66  }
67 
68 protected:
69  // @override
70  bool to_string(string& out);
71 
72  // @override
73  int update(const char* data, int dlen);
74 
75  // @override
76  bool finished(void) const {
77  return finished_;
78  }
79 
80 public:
81  /**
82  * (internal) update mqtt header data for parsing mqtt data.
83  * @param data {const char*} the data to be parsed.
84  * @param dlen {int} the length of data.
85  * @return {int} return the length of the left data.
86  */
87  int update_header_var(const char* data, int dlen);
88 
89 private:
90  unsigned status_;
91  bool finished_;
92  char buff_[2];
93  int dlen_;
94 
95  bool session_;
96  unsigned char conn_flags_;
97  unsigned char connack_code_;
98 };
99 
100 } // namespace acl
bool finished(void) const
bool get_session(void) const
unsigned char get_connack_code(void) const
#define ACL_CPP_API