The QMqttPublishProperties class represents configuration options for sending or receiving a message. 更多...
头: | #include <QMqttPublishProperties> |
qmake: | QT += mqtt |
Since: | Qt 5.12 |
enum | PublishPropertyDetail { None, PayloadFormatIndicator, MessageExpiryInterval, TopicAlias, ResponseTopic, …, ContentType } |
flags | PublishPropertyDetails |
QMqttPublishProperties::PublishPropertyDetails | availableProperties () const |
QString | contentType () const |
QByteArray | correlationData () const |
quint32 | messageExpiryInterval () const |
QMqtt::PayloadFormatIndicator | payloadFormatIndicator () const |
QString | responseTopic () const |
void | setContentType (const QString & type ) |
void | setCorrelationData (const QByteArray & correlation ) |
void | setMessageExpiryInterval (quint32 interval ) |
void | setPayloadFormatIndicator (QMqtt::PayloadFormatIndicator indicator ) |
void | setResponseTopic (const QString & topic ) |
void | setSubscriptionIdentifiers (const QList<quint32> & ids ) |
void | setTopicAlias (quint16 alias ) |
void | setUserProperties (const QMqttUserProperties & properties ) |
QList<quint32> | subscriptionIdentifiers () const |
quint16 | topicAlias () const |
QMqttUserProperties | userProperties () const |
Invoking QMqttClient::publish () to send a message to a broker can include QMqttPublishProperties to provide additional arguments on how the message should be treated on the broker.
Furthermore receiving a message by an instantiated subscription might contain publish properties which have been forwarded or adapted by the server.
注意: Publish properties are part of the MQTT 5.0 specification and cannot be used when connecting with a lower protocol level. See QMqttClient::ProtocolVersion 了解更多信息。
This enum type specifies the available properties set by the server or the client when creating a message.
常量 | 值 | 描述 |
---|---|---|
QMqttPublishProperties::None
|
0x00000000
|
No property has been specified. |
QMqttPublishProperties::PayloadFormatIndicator
|
0x00000001
|
The type of content of the message. |
QMqttPublishProperties::MessageExpiryInterval
|
0x00000002
|
The duration a message is valid. |
QMqttPublishProperties::TopicAlias
|
0x00000004
|
The topic alias for this message. |
QMqttPublishProperties::ResponseTopic
|
0x00000008
|
The topic the receipient should respond to. |
QMqttPublishProperties::CorrelationData
|
0x00000010
|
An identifier of the response message. |
QMqttPublishProperties::UserProperty
|
0x00000020
|
Additional properties set by the user. |
QMqttPublishProperties::SubscriptionIdentifier
|
0x00000040
|
An identifier of subscriptions matching the publication. |
QMqttPublishProperties::ContentType
|
0x00000080
|
A description of the content of the message. |
The PublishPropertyDetails type is a typedef for QFlags <PublishPropertyDetail>. It stores an OR combination of PublishPropertyDetail values.
Returns the available properties specified in this instance. When a message is created, it does not need to include all properties. This function serves as an indicator of those properties which have been explicitly set.
Returns the content type of the message.
另请参阅 setContentType ().
Returns the correlation data.
另请参阅 setCorrelationData ().
Returns the message expiry interval. This value specifies the number of seconds a server is allowed to forward the message. If the interval expires, the server must delete the message and abort publishing it.
另请参阅 setMessageExpiryInterval ().
Returns the payload format indicator.
另请参阅 setPayloadFormatIndicator ().
Returns the response topic a user should use as a follow up to a request.
另请参阅 setResponseTopic ().
Sets the content type of the message to type .
另请参阅 contentType ().
Sets the correlation data to correlation .
另请参阅 correlationData ().
Sets the message expiry interval to interval .
另请参阅 messageExpiryInterval ().
Sets the payload format indicator to indicator .
另请参阅 payloadFormatIndicator ().
Sets the response topic to topic .
另请参阅 responseTopic ().
Sets the subscription identifiers to ids .
另请参阅 subscriptionIdentifiers ().
Sets the topic alias for publishing a message to alias . A topic alias value must be greater than zero and less than the maximum topic alias specified by the server.
另请参阅 topicAlias () 和 QMqttServerConnectionProperties::maximumTopicAlias ().
Sets the user properties of a message to properties .
另请参阅 userProperties ().
Returns the subscription identifiers of subscriptions matching the topic filter of the message.
另请参阅 setSubscriptionIdentifiers ().
Returns the topic alias used for publishing a message.
另请参阅 setTopicAlias ().
Returns the user properties of a message.
另请参阅 setUserProperties ().