diff options
author | Leena Miettinen <riitta-leena.miettinen@qt.io> | 2017-10-25 13:18:51 +0200 |
---|---|---|
committer | Leena Miettinen <riitta-leena.miettinen@qt.io> | 2017-10-26 07:12:28 +0000 |
commit | 7bc7efd1b97b942c5b21e9c5a1908519ab3fdbe4 (patch) | |
tree | 9a9b4270601e84f31d6320badc82eefbbe1b6aa2 /examples | |
parent | 22598170f61eac7eebb95df190f904e9dc3003ba (diff) |
Doc: Add docs for MQTT Subscriptions example
Change-Id: Ia5c3b6cc76f6938f4b315215f0c8351f6ae434d9
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
Diffstat (limited to 'examples')
-rw-r--r-- | examples/mqtt/doc/images/subscriptions.png | bin | 0 -> 63728 bytes | |||
-rw-r--r-- | examples/mqtt/doc/subscriptions.qdoc | 50 |
2 files changed, 47 insertions, 3 deletions
diff --git a/examples/mqtt/doc/images/subscriptions.png b/examples/mqtt/doc/images/subscriptions.png Binary files differnew file mode 100644 index 0000000..9480ea7 --- /dev/null +++ b/examples/mqtt/doc/images/subscriptions.png diff --git a/examples/mqtt/doc/subscriptions.qdoc b/examples/mqtt/doc/subscriptions.qdoc index ae894d5..dae8e44 100644 --- a/examples/mqtt/doc/subscriptions.qdoc +++ b/examples/mqtt/doc/subscriptions.qdoc @@ -54,8 +54,52 @@ \ingroup qtmqtt-examples \brief Creating a application that communicates with an MQTT broker. - \e {MQTT Subscriptions} shows how to use the QMqttClient, QMqttSubscription, - and QMqttMessage classes for creating an application communicating with an - MQTT broker. + \image subscriptions.png + \e {MQTT Subscriptions} shows how to create an application that communicates + with an MQTT broker. A new dialog opens for each subscription, where you can + see the messages on the subscribed topics. + + \section1 Creating a Client + + We use the QMqttClient class to create an MQTT client and to set the broker + host name and port to use for the connection: + + \quotefromfile subscriptions/mainwindow.cpp + \skipto m_client + \printuntil setPort + + \section1 Subscribing to Topics + + When users subscribe to topics in the client, a new subscription object is + created: + + \skipto on_buttonSubscribe_clicked + \printuntil } + \printuntil } + + We use the QMqttSubscription class to store the topic, state, and QoS level + of a subscription: + + \quotefromfile subscriptions/subscriptionwindow.cpp + \skipto QMqttSubscription + \printuntil }); + \printuntil } + + The QoS level can be set separately for a message and for a subscription. + The QoS level set for a subscription determines the minimum QoS level. If + a message is sent with a higher QoS level, the broker increases the QoS of + that message to the higher level. For example, if client A subscribed to + \e topic with QoS 1, and client B publishes a message on the topic, with + QoS 0, the broker will automatically increase the QoS of the message to 1. + If client B publishes a message on the topic with the QoS 2, the broker + will send it with QoS 2. + + \section2 Receiving Messages + + When the client receives a message, the QMqttMessage class is used to store + the actual message payload: + + \skipto updateMessage + \printuntil } */ |