QMqttMessage Class

The QMqttMessage class provides information about a message received from a message broker based on a subscription. 更多...

頭: #include <QMqttMessage>
qmake: QT += mqtt

特性

公共函數

QMqttMessage (const QMqttMessage & other )
QMqttMessage ()
QMqttMessage & operator= (const QMqttMessage & other )
bool duplicate () const
quint16 id () const
const QByteArray & payload () const
QMqttPublishProperties publishProperties () const
quint8 qos () const
bool retain () const
QMqttTopicName topic () const
bool operator!= (const QMqttMessage & other ) const
bool operator== (const QMqttMessage & other ) const

詳細描述

An MQTT message is created inside the module and returned via the QMqttSubscription::messageReceived () 信號。

特性文檔編製

duplicate : const bool

This property holds whether the message is a duplicate.

Duplicate messages indicate that the message has been sent earlier, but it has not been confirmed yet. Hence, the broker assumes that it needs to resend to verify the transport of the message itself. Duplicate messages can only occur if the QoS level is one or two.

訪問函數:

bool duplicate () const

id : const quint16

This property holds the ID of the message.

IDs are used for messages with a QoS level above zero.

訪問函數:

quint16 id () const

payload : const QByteArray

This property holds the payload of a message.

訪問函數:

const QByteArray & payload () const

qos : const quint8

This property holds the QoS level of a message.

訪問函數:

quint8 qos () const

retain : const bool

This property holds whether the message has been retained.

A retained message is kept on the broker for future clients to subscribe. Consequently, a retained message has been created previously and is not a live update. A broker can store only one retained message per topic.

訪問函數:

bool retain () const

topic : const QMqttTopicName

This property holds the topic of a message.

In case a wildcard has been used for a subscription, describes the topic matching this subscription. This property never contains wildcards.

訪問函數:

QMqttTopicName topic () const

成員函數文檔編製

QMqttMessage:: QMqttMessage (const QMqttMessage & other )

Constructs a new MQTT message that is a copy of other .

QMqttMessage:: QMqttMessage ()

Creates a new MQTT message.

QMqttMessage &QMqttMessage:: operator= (const QMqttMessage & other )

Makes this object a copy of other and returns the new value of this object.

QMqttPublishProperties QMqttMessage:: publishProperties () const

Returns the publish properties received as part of the message.

注意: This function only specifies the properties when a publish message is received. Messages with a QoS value of 1 or 2 can contain additional properties when a message is released. Those can be obtained by the QMqttClient::messageStatusChanged 信號。

注意: This function will only provide valid data when the client specifies QMqttClient::MQTT_5_0 as QMqttClient::ProtocolVersion .

該函數在 Qt 5.12 引入。

bool QMqttMessage:: operator!= (const QMqttMessage & other ) const

返迴 true if the message and other are not equal, otherwise returns false .

bool QMqttMessage:: operator== (const QMqttMessage & other ) const

返迴 true if the message and other 相等,否則返迴 false .