new Core.ModelList.Layer.SensorThingsMqtt.exports.SensorThingsMqttClient(mqttClient, mqttHost, context)
modules/core/modelList/layer/sensorThingsMqtt.js, line 72
The SensorThingsMqttClient - received calling SensorThingsMqtt.connect
| Name | Type | Description |
|---|---|---|
mqttClient |
mqtt/mqttClient | the mqtt client (e.g. from npm mqtt) |
mqttHost |
String | the mqtt host |
context |
Object | the context to call events in (e.g. this) |
Methods
-
getMqttClient(){mqtt/mqttClient}
modules/core/modelList/layer/sensorThingsMqtt.js, line 216 -
returns the currently used mqttClient
Returns:
currently used mqtt client
-
on(eventName, handler){Void}
modules/core/modelList/layer/sensorThingsMqtt.js, line 149 -
if eventName equals 'message', handler is set as instance variable messageHandler - later used for the simulation of retained messages
Name Type Description eventNameString the name of the mqtt event (connect, message, close, end, error) handlerSensorThingsMqttCallbackMessage the event handler -
subscribe(topic, optionsOpt, onmessageOpt){Void}
modules/core/modelList/layer/sensorThingsMqtt.js, line 185 -
function to subscribe to a topic
Name Type Description topicString the SensorThings topic to subscribe at optionsOptObject optional a few options that can be set Name Type Default Description qosNumber 0 optional flag of how to set quality of service for this subscription - see: https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901169 retainNumber 0 optional flag of how to use retained messages for this subscription - see: https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc385349265 rmSimulateBoolean true optional false if no simulation of retained messages should take place, otherwise true rmPathString "" optional a path on the server in case the path differs from the standard implementation rmProtocolString "https" optional the protocol to use for the simulation (http, https, ...) rmHttpClientSensorThingsClientHttp optional a function to call an url with for the simulation instead of using the default (defaultHttpClient) onmessageOptSensorThingsMqttCallbackMessage optional a function to be called for receiving the message, default: messageHandler -
unsubscribe(topic){Void}
modules/core/modelList/layer/sensorThingsMqtt.js, line 208 -
unsubscribes from the server
Name Type Description topicString the SensorThings topic to unsubscribe from