summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorMate Barany <mate.barany@qt.io>2023-04-26 17:25:09 +0200
committerMate Barany <mate.barany@qt.io>2023-05-23 17:20:05 +0200
commite96f355983f784bd43ed986262e2375410178a2b (patch)
tree4435ad269136a4c2ee66c93be308816e359f724a /examples
parente6eedb4d037755c00aec8b00fc5475d1c598f4f7 (diff)
Revamp documentation of the Websockets MQTT Subscription Example
Remove "Example" from the name of the example. Add examplecategory. Add a short explanation and a few code snippets. Task-number: QTBUG-110893 Change-Id: I0e4e29b9cd86c4950fdd0263ecec54e8927b2c3c Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'examples')
-rw-r--r--examples/mqtt/doc/websocketsubscription.qdoc36
1 files changed, 35 insertions, 1 deletions
diff --git a/examples/mqtt/doc/websocketsubscription.qdoc b/examples/mqtt/doc/websocketsubscription.qdoc
index 3353bf8..01e4f37 100644
--- a/examples/mqtt/doc/websocketsubscription.qdoc
+++ b/examples/mqtt/doc/websocketsubscription.qdoc
@@ -3,7 +3,8 @@
/*!
\example websocketsubscription
- \title WebSockets MQTT Subscription Example
+ \examplecategory {Connectivity}
+ \title WebSockets MQTT Subscription
\ingroup qtmqtt-examples
\brief Combining an MQTT client with a web socket connection.
@@ -11,4 +12,37 @@
QIODevice to combine a \l {Qt WebSockets}{web socket} connection with
QMqttClient.
+ \section1 Creating a Custom QIODevice
+
+ The new custom device, \c WebSocketIODevice, has to be a subclass of
+ \l QIODevice:
+
+ \quotefromfile websocketsubscription/websocketiodevice.h
+ \skipto WebSocketIODevice
+ \printuntil }
+
+ \section1 Designing a Class to Manage the Connection and Subscription
+
+ \c WebSocketIODevice will be a private member of the \c ClientSubscription
+ class alongside the QMqttClient and the QMqttSubscription:
+
+ \quotefromfile websocketsubscription/clientsubscription.h
+ \skipto private
+ \printuntil m_version
+
+ \section1 Subscribing to and Receiving Messages
+
+ The main logic is implemented in the \c connectAndSubscribe() method of the
+ \c ClientSubscription class. You need to verify that the web socket has
+ successfully connected before you can initialize an MQTT connection over
+ it. After the MQTT connection has been established, the QMqttClient can
+ subscribe to the topic. If the subscription is successful, the
+ QMqttSubscription can be used to receive messages from the subscribed topic
+ that will be handled by the \c handleMessage() method of the
+ \c ClientSubscription class.
+
+ \quotefromfile websocketsubscription/clientsubscription.cpp
+ \skipto connectAndSubscribe
+ \printuntil Could
+ \printuntil }
*/