.. _object_MqttBroker: :index:`MqttBroker` ------------------- Description *********** The MqttBroker object creates an MQTT broker listening for connections. An MQTT broker manages the exchange of subscribed and published topics for all connected clients. :**› Inherits**: :ref:`Object ` Overview ******** Properties ++++++++++ .. hlist:: :columns: 1 * :ref:`enabled ` * :ref:`internal ` * :ref:`listeners ` * :ref:`maxConnections ` * :ref:`Object.objectId ` * :ref:`Object.parent ` Methods +++++++ .. hlist:: :columns: 1 * :ref:`Object.deserializeProperties() ` * :ref:`Object.fromJson() ` * :ref:`Object.serializeProperties() ` * :ref:`Object.toJson() ` Signals +++++++ .. hlist:: :columns: 1 * :ref:`listenersDataChanged() ` * :ref:`Object.completed() ` Properties ********** .. _property_MqttBroker_enabled: .. _signal_MqttBroker_enabledChanged: .. index:: single: enabled enabled +++++++ This property holds whether the broker is enabled. If set to ``false`` the broker process is stopped. :**› Type**: Boolean :**› Default**: ``true`` :**› Signal**: enabledChanged() :**› Attributes**: Writable .. _property_MqttBroker_internal: .. _signal_MqttBroker_internalChanged: .. index:: single: internal internal ++++++++ This property holds whether the broker should listen for incoming connections on the local loopback interface only. If set to ``true`` the broker will not be reachable by other hosts on the network but internal clients such as docker containers (:ref:`DockerContainer `) only. :**› Type**: Boolean :**› Default**: ``true`` :**› Signal**: internalChanged() :**› Attributes**: Writable .. _property_MqttBroker_listeners: .. _signal_MqttBroker_listenersChanged: .. index:: single: listeners listeners +++++++++ This property holds a list of :ref:`MqttListener ` objects which define the actual connectivity options of the broker. This property was introduced in InCore 2.6. :**› Type**: :ref:`List `\<:ref:`MqttListener `> :**› Signal**: listenersChanged() :**› Attributes**: Readonly .. _property_MqttBroker_maxConnections: .. _signal_MqttBroker_maxConnectionsChanged: .. index:: single: maxConnections maxConnections ++++++++++++++ This property holds the maximum number of connections which the broker is allowed to manage concurrently. :**› Type**: SignedInteger :**› Default**: ``-1`` :**› Signal**: maxConnectionsChanged() :**› Attributes**: Writable, Optional Signals ******* .. _signal_MqttBroker_listenersDataChanged: .. index:: single: listenersDataChanged listenersDataChanged(SignedInteger index) +++++++++++++++++++++++++++++++++++++++++ This signal is emitted whenever the :ref:`List.dataChanged() ` signal is emitted, i.e. the item at ``index`` in the :ref:`listeners ` list itself emitted the dataChanged() signal. .. _example_MqttBroker: Example ******* .. code-block:: qml import InCore.Foundation 2.6 import InCore.Mqtt 2.6 Application { name: "MqttBrokerExample" Settings { id: settings property bool brokerEnabled : true; } // start an MQTT broker if enabled via settings MqttBroker { enabled: settings.brokerEnabled listeners: [ MqttListener { internal: false port: 1883 }, MqttListener { internal: false port: 1884 protocol: MqttListener.Websockets } ] } }