The MQTTListener SIB Listener listens to a topic on an MQTT service that might differ from the internal MQTT transport. When a message arrives the workflow is triggered.
Module | sib_mqttlistener |
Version | 1.3.5 |
var MQTTServiceCustom = { _id: "mqttSample:1", _name: "SIB MQTT Listener Sample", buildSIBMsg: (topic, msg )=>{ return msg; }, init: ( thisListener )=>{}, inputFormat: (topic, msg, callback)=>{ msg.fmtData = "Data has been formatted and modified"; callback( msg ); }, loggerCfg: { dest: { file: false, console: true, mqtt: true } }, outputFormat: (topic, msg, callback)=>{ msg.outData = "output sent"; callback(msg); }, mqtt: "mqtt://localhost", publishOutput: (msg, mqttClient)=>{ mqttClient.publish( msg.responseTopic, JSON.stringify( msg ) ); }, publishInput: (msg, mqttClient)=>{ mqttClient.publish( msg._sibheader.topic, JSON.stringify( msg ) ); }, responseFilter: (topic, msg )=>{ return true; }, src: { mqtt: "mqtt://localhost", topic: "SIB/G2I.001/CRON/+", useenv: false }, topic: "SIB/Samples/MQTTListener" }; module.exports = MQTTServiceCustom;