acl  3.5.3.0
acl::mqtt_client类 参考

#include <mqtt_client.hpp>

+ 类 acl::mqtt_client 继承关系图:
+ acl::mqtt_client 的协作图:

Public 成员函数

 mqtt_client (const char *addr, int conn_timeout=10, int rw_timeout=10)
 
 mqtt_client (acl::socket_stream &conn)
 
 ~mqtt_client (void)
 
bool send (mqtt_message &message)
 
mqtt_messageget_message (void)
 
bool read_header (mqtt_header &header)
 
bool read_message (const mqtt_header &header, mqtt_message &body)
 
- Public 成员函数 继承自 acl::connect_client
 connect_client (void)
 
virtual ~connect_client ()
 
time_t get_when ()
 
void set_when (time_t when)
 
connect_poolget_pool () const
 
virtual void set_timeout (int conn_timeout, int rw_timeout)
 

Protected 成员函数

bool open (void)
 
- Protected 成员函数 继承自 acl::connect_client
void set_pool (connect_pool *pool)
 
- Protected 成员函数 继承自 acl::acl::noncopyable
 noncopyable ()
 
 ~noncopyable ()
 

额外继承的成员函数

- Protected 属性 继承自 acl::connect_client
int conn_timeout_
 
int rw_timeout_
 
time_t when_
 
connect_poolpool_
 

详细描述

mqtt communication class in sync mode, used by mqtt client or mqtt server.

在文件 mqtt_client.hpp15 行定义.

构造及析构函数说明

◆ mqtt_client() [1/2]

acl::mqtt_client::mqtt_client ( const char *  addr,
int  conn_timeout = 10,
int  rw_timeout = 10 
)

used to construct one mqtt client for connecting one mqtt server.

参数
addr{const char*} the mqtt server's addr with the format like ip|port or domain|port.
conn_timeout{int} the timeout for connecting mqtt server.
rw_timeout{int} the timeout for reading from mqtt connection.

◆ mqtt_client() [2/2]

acl::mqtt_client::mqtt_client ( acl::socket_stream conn)

used to construct one mqtt client for connecting mqtt server, or receiving from mqtt client.

参数
conn{acl::socket_stream&}

◆ ~mqtt_client()

acl::mqtt_client::~mqtt_client ( void  )

成员函数说明

◆ get_message()

mqtt_message* acl::mqtt_client::get_message ( void  )

read mqtt data from mqtt connection and create the correspondingly mqtt message object with the mqtt type from mqtt header.

返回
{mqtt_message*} return NULL if reading error or data invalid.

◆ open()

bool acl::mqtt_client::open ( void  )
protectedvirtual

实现了 acl::connect_client.

◆ read_header()

bool acl::mqtt_client::read_header ( mqtt_header header)

read mqtt header information from mqtt connection.

参数
header{const mqtt_header&} will store the mqtt headeer info.
返回
{bool} return true if reading successfully.

◆ read_message()

bool acl::mqtt_client::read_message ( const mqtt_header header,
mqtt_message body 
)

read mqtt body information from mqtt connection.

参数
header{const mqtt_header&} used to parse mqtt body.
body{mqtt_message&} will store mqtt body info.
返回
{bool} return true if reading successfully.

◆ send()

bool acl::mqtt_client::send ( mqtt_message message)

send ont mqtt message to the peer mqtt.

参数
message{mqtt_message&} the mqtt message to be sent, where some viriable method of the mesage will be called, so we can't add the const limit on it.
返回
{bool} return true if sending successfully.

该类的文档由以下文件生成: