mirror of
https://gitee.com/acl-dev/acl.git
synced 2024-12-14 08:50:53 +08:00
38 lines
722 B
C++
38 lines
722 B
C++
#pragma once
|
|
|
|
#include "../stdlib/string.hpp"
|
|
#include "../connpool/connect_client.hpp"
|
|
#include "../stream/socket_stream.hpp"
|
|
|
|
namespace acl {
|
|
|
|
class mqtt_message;
|
|
|
|
class ACL_CPP_API mqtt_client : public connect_client {
|
|
public:
|
|
mqtt_client(const char* addr, int conn_timeout = 10, int rw_timeout = 10);
|
|
~mqtt_client(void);
|
|
|
|
bool send(mqtt_message& message);
|
|
|
|
mqtt_message* get_message(void);
|
|
|
|
public:
|
|
bool read_header(mqtt_message& header);
|
|
bool read_body(const mqtt_message& header, mqtt_message& body);
|
|
mqtt_message* create_body(const mqtt_message& header);
|
|
|
|
protected:
|
|
// @override
|
|
bool open(void);
|
|
|
|
private:
|
|
string addr_;
|
|
int conn_timeout_;
|
|
int rw_timeout_;
|
|
|
|
socket_stream conn_;
|
|
};
|
|
|
|
} // namespace acl
|