acl  3.5.3.0
acl::mqtt_message类 参考abstract

#include <mqtt_message.hpp>

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

Public 成员函数

 mqtt_message (mqtt_type_t type)
 
 mqtt_message (const mqtt_header &header)
 
virtual ~mqtt_message (void)
 
virtual bool to_string (string &out)=0
 
virtual int update (const char *data, int dlen)=0
 
virtual bool finished (void) const
 
mqtt_headerget_header (void)
 
const mqtt_headerget_header (void) const
 

静态 Public 成员函数

static mqtt_messagecreate_message (const mqtt_header &header)
 

Protected 成员函数

void pack_add (unsigned char ch, string &out)
 
void pack_add (unsigned short n, string &out)
 
void pack_add (const string &s, string &out)
 
bool unpack_short (const char *data, size_t len, unsigned short &out)
 

Protected 属性

mqtt_header header_
 

详细描述

the pure virtual class for creating one mqtt message object from or to mqtt message data, all subclass of it should implement the pure virtual method. Any subclass of it can be used to parse mqtt data to create mqtt message, or serialize to string data from mqtt message.

在文件 mqtt_message.hpp14 行定义.

构造及析构函数说明

◆ mqtt_message() [1/2]

acl::mqtt_message::mqtt_message ( mqtt_type_t  type)

create message object to be used for sending message to peer.

参数
type{mqtt_type_t}

◆ mqtt_message() [2/2]

acl::mqtt_message::mqtt_message ( const mqtt_header header)

create message object after receiving message data from peer, because the mqtt message includes header and body, so we parse the protocol data in two steps: frist parsing the mqtt header, and then parsing the mqtt body.

参数
header{const mqtt_header&} created from the mqtt data and passed to the message object to be created.

◆ ~mqtt_message()

virtual acl::mqtt_message::~mqtt_message ( void  )
virtual

virtual destructor.

成员函数说明

◆ create_message()

static mqtt_message* acl::mqtt_message::create_message ( const mqtt_header header)
static

create mqtt message object with the specified mqtt header after parsing the mqtt data.

参数
header{const mqtt_header&}
返回
{mqtt_message*} return no-NULL if successful, or NULL if the mqtt object type of header is invalid.

◆ finished()

virtual bool acl::mqtt_message::finished ( void  ) const
inlinevirtual

check if the current mqtt object been parsing from mqtt data has been completed.

返回
{bool}

acl::mqtt_publish, acl::mqtt_connack, acl::mqtt_subscribe, acl::mqtt_suback, acl::mqtt_ack, acl::mqtt_unsubscribe, acl::mqtt_connect, acl::mqtt_disconnect, acl::mqtt_pingreq , 以及 acl::mqtt_pingresp 重载.

在文件 mqtt_message.hpp66 行定义.

66  {
67  return false;
68  }

◆ get_header() [1/2]

mqtt_header& acl::mqtt_message::get_header ( void  )
inline

get the current mqtt message header in variable mode in order to change some information of the header.

返回
{mqtt_header&}

在文件 mqtt_message.hpp75 行定义.

75  {
76  return header_;
77  }
mqtt_header header_

◆ get_header() [2/2]

const mqtt_header& acl::mqtt_message::get_header ( void  ) const
inline

get the current mqtt message header in invariable mode, just for getting some information from it.

返回
{const mqtt_header&}

在文件 mqtt_message.hpp84 行定义.

84  {
85  return header_;
86  }
mqtt_header header_

◆ pack_add() [1/3]

void acl::mqtt_message::pack_add ( unsigned char  ch,
string out 
)
protected

◆ pack_add() [2/3]

void acl::mqtt_message::pack_add ( unsigned short  n,
string out 
)
protected

◆ pack_add() [3/3]

void acl::mqtt_message::pack_add ( const string s,
string out 
)
protected

◆ to_string()

virtual bool acl::mqtt_message::to_string ( string out)
pure virtual

the subclass should implement this method to build mqtt message data, this is used as the mqtt message serialize.

参数
out{string&} used to store the mqtt data.
返回
{bool} return true if serialize sucessfully.

acl::mqtt_publish, acl::mqtt_connack, acl::mqtt_subscribe, acl::mqtt_suback, acl::mqtt_ack, acl::mqtt_unsubscribe, acl::mqtt_connect, acl::mqtt_disconnect, acl::mqtt_pingreq , 以及 acl::mqtt_pingresp 内被实现.

◆ unpack_short()

bool acl::mqtt_message::unpack_short ( const char *  data,
size_t  len,
unsigned short &  out 
)
protected

◆ update()

virtual int acl::mqtt_message::update ( const char *  data,
int  dlen 
)
pure virtual

the subclass should implement this method to parse mqtt data, this is used as the mqtt message deserialize.

参数
data{char*} mqtt message data received from socket.
dlen{int} the length of data.
返回
{int} return the length of left data not consumed:

0: the current mqtt message object has been finished, the left

data is for the next message object; -1: some error happened when parsing the mqtt message data; 0: all the data passed in has been consumed by the current mqtt message object, the object maybe complete or not, you should call finished() to check if the object has been completed.

acl::mqtt_publish, acl::mqtt_connack, acl::mqtt_subscribe, acl::mqtt_suback, acl::mqtt_ack, acl::mqtt_unsubscribe, acl::mqtt_connect, acl::mqtt_disconnect, acl::mqtt_pingreq , 以及 acl::mqtt_pingresp 内被实现.

类成员变量说明

◆ header_

mqtt_header acl::mqtt_message::header_
protected

在文件 mqtt_message.hpp99 行定义.


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