How to use the mqtt.MqttServer function in mqtt

To help you get started, we’ve selected a few mqtt examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github phodal / lan / test / server / mqtt_spec.js View on Github external
beforeEach(function () {
    mqttServer = mqtt.MqttServer(app.mqtt).listen(1883, function () {
    });
  });
github phodal / designiot-code / chapter7 / lan / app.js View on Github external
db.find(payload, function (results) {
        if (results.length > 0) {
            db.update(data);
            res.send({db: "update"});
        } else {
            db.insert(data);
            res.send({db: "insert"});
        }
    });
});

app.listen(3000, function () {
    console.log("server run on http://localhost:%d", 3000);
});

mqtt.MqttServer(mqttServer).listen(1883, function () {
    console.log("mqtt server listening on port %d", 1883);
});

coap.createServer(coapServer).listen(5683, function () {
    console.log("coap server listening on port %d", 5683);
});
github phodal / lan / server.js View on Github external
if (_.include(app.config.get('modules'), 'websocket')) {
    var webSocketServer = new WebSocketServer({port: config.get('port.websocket')});
    app.websocket(webSocketServer);
    console.log("websocket server listening on port %d", config.get('port.websocket'));
  }

  if (_.include(app.config.get('modules'), 'coap')) {
    coap.createServer(app.coap).listen(config.get('port.coap'), function () {
      console.log("coap server listening on port %d", config.get('port.coap'));
    });
  }

  if (_.include(app.config.get('modules'), 'mqtt')) {
    mqtt.MqttServer(app.mqtt).listen(config.get('port.mqtt'), function () {
      console.log("mqtt server listening on port %d", config.get('port.mqtt'));
    });
  }
  return app;
};