The QMqttSubscription class receives notifications from an MQTT broker about a specified topic. More...
Header: | #include <QMqttSubscription> |
qmake: | QT += mqtt |
Inherits: | QObject |
enum | SubscriptionState { Unsubscribed, SubscriptionPending, Subscribed, UnsubscriptionPending, Error } |
|
|
virtual | ~QMqttSubscription() override |
bool | isSharedSubscription() const |
quint8 | qos() const |
QString | reason() const |
QMqtt::ReasonCode | reasonCode() const |
QString | sharedSubscriptionName() const |
QMqttSubscription::SubscriptionState | state() const |
QMqttTopicFilter | topic() const |
QMqttUserProperties | userProperties() const |
void | unsubscribe() |
void | messageReceived(QMqttMessage msg) |
void | qosChanged(quint8) |
void | stateChanged(QMqttSubscription::SubscriptionState state) |
This enum type describes the states a subscription can have.
Constant | Value | Description |
---|---|---|
QMqttSubscription::Unsubscribed |
0 |
The topic has been unsubscribed from. |
QMqttSubscription::SubscriptionPending |
1 |
A request for a subscription has been sent, but is has not been confirmed by the broker yet. |
QMqttSubscription::Subscribed |
2 |
The subscription was successful and messages will be received. |
QMqttSubscription::UnsubscriptionPending |
3 |
A request to unsubscribe from a topic has been sent, but it has not been confirmed by the broker yet. |
QMqttSubscription::Error |
4 |
An error occured. |
[read-only]
qos : const quint8
This property holds the QoS level at which the subscription has been made.
The QoS level of the subscription specifies the maximum QoS level at which the client will receive messages. The publisher can still send messages at a lower level.
Access functions:
quint8 | qos() const |
Notifier signal:
void | qosChanged(quint8) |
[read-only, since 5.12]
reason : const QString
This property holds the reason string for the subscription.
A reason string is used by the server to provide additional information about the subscription. It is optional for the server to send it.
This property was introduced in Qt 5.12.
Access functions:
QString | reason() const |
[read-only, since 5.12]
reasonCode : const QMqtt::ReasonCode
This property holds the reason code for the subscription.
The reason code specifies the error type if a subscription has failed, or the level of QoS for success.
This property was introduced in Qt 5.12.
Access functions:
QMqtt::ReasonCode | reasonCode() const |
[read-only, since 5.12]
sharedSubscription : const bool
This property holds whether the subscription is shared.
This property was introduced in Qt 5.12.
Access functions:
bool | isSharedSubscription() const |
[read-only, since 5.12]
sharedSubscriptionName : const QString
This property holds the name of the shared subscription.
This property was introduced in Qt 5.12.
Access functions:
QString | sharedSubscriptionName() const |
[read-only]
state : const SubscriptionState
This property holds the state of the subscription.
Access functions:
QMqttSubscription::SubscriptionState | state() const |
Notifier signal:
void | stateChanged(QMqttSubscription::SubscriptionState state) |
[read-only]
topic : const QMqttTopicFilter
This property holds the topic of the subscription.
Access functions:
QMqttTopicFilter | topic() const |
[signal]
void QMqttSubscription::messageReceived(QMqttMessage msg)
This signal is emitted when the new message msg has been received.
[slot]
void QMqttSubscription::unsubscribe()
Unsubscribes from topic.
Note: This might affect all shared pointer instances returned by QMqttClient::subscribe().
[override virtual]
QMqttSubscription::~QMqttSubscription()
Deletes a subscription. If the topic was not already unsubscribed from, it will be unsubscribed from automatically.
[since 5.12]
QMqttUserProperties QMqttSubscription::userProperties() const
Returns the user properties received from the broker when the subscription has been accepted.
Note: This function will only provide valid data when the client specifies QMqttClient::MQTT_5_0 as QMqttClient::ProtocolVersion.
This function was introduced in Qt 5.12.
© The Qt Company Ltd
Licensed under the GNU Free Documentation License, Version 1.3.
https://doc.qt.io/qt-6.2/qmqttsubscription.html