.. _object_MqttSubscription: :index:`MqttSubscription` ------------------------- Description *********** The MqttSubscription object manages subscriptions of one or multiple MQTT :ref:`topics ` published by another instance on the MQTT broker. Unless disabled explicitely via the :ref:`MqttAbstractSubscription.autoSubscribe ` property all topics are subscribed automatically. The parent object must be of type :ref:`MqttClient `. :**› Inherits**: :ref:`MqttAbstractSubscription ` Overview ******** Properties ++++++++++ .. hlist:: :columns: 2 * :ref:`topics ` * :ref:`MqttAbstractSubscription.autoSubscribe ` * :ref:`MqttAbstractSubscription.enabled ` * :ref:`MqttAbstractSubscription.error ` * :ref:`MqttAbstractSubscription.errorString ` * :ref:`MqttAbstractSubscription.qos ` * :ref:`MqttAbstractSubscription.subscribed ` * :ref:`Object.objectId ` * :ref:`Object.parent ` Methods +++++++ .. hlist:: :columns: 1 * :ref:`MqttAbstractSubscription.subscribe() ` * :ref:`MqttAbstractSubscription.unsubscribe() ` * :ref:`Object.deserializeProperties() ` * :ref:`Object.fromJson() ` * :ref:`Object.serializeProperties() ` * :ref:`Object.toJson() ` Signals +++++++ .. hlist:: :columns: 1 * :ref:`topicsDataChanged() ` * :ref:`MqttAbstractSubscription.errorOccurred() ` * :ref:`Object.completed() ` Enumerations ++++++++++++ .. hlist:: :columns: 1 * :ref:`MqttAbstractSubscription.Error ` Properties ********** .. _property_MqttSubscription_topics: .. _signal_MqttSubscription_topicsChanged: .. index:: single: topics topics ++++++ This property holds a list of MQTT topics to subscribe. :**› Type**: :ref:`List `\<:ref:`MqttTopic `> :**› Signal**: topicsChanged() :**› Attributes**: Readonly Signals ******* .. _signal_MqttSubscription_topicsDataChanged: .. index:: single: topicsDataChanged topicsDataChanged(SignedInteger index) ++++++++++++++++++++++++++++++++++++++ This signal is emitted whenever the :ref:`List.dataChanged() ` signal is emitted, i.e. the item at ``index`` in the :ref:`topics ` list itself emitted the dataChanged() signal. .. _example_MqttSubscription: Example ******* .. code-block:: qml import InCore.Foundation 2.5 import InCore.Mqtt 2.5 Application { MqttClient { clientId: "MqttSubscriptionExample" hostname: "localhost" MqttSubscription { qos: 1 onSubscribedChanged: console.log("Subscribed to topics") MqttTopic { name: "incore/temperature" dataType: MqttTopic.Float onDataChanged: console.log("Device temperature changed to", data) } MqttTopic { name: "incore/foo/counter" onDataChanged: console.log("Counter changed to", data) } MqttTopic { name: "incore/bar/date" dataType: DataObject.DateTime onDataChanged: console.log("Date changed to", data) } MqttTopic { name: "incore/array" dataType: DataObject.StringList onDataChanged: console.log("Array data:", data) } } } }