How to use the mqtt.Server 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 digsjs / digs / lib / common / mqtt / broker.js View on Github external
function createServer(opts) {
  opts = _.defaults(opts || {}, {
    port: DEFAULT_PORT,
    host: DEFAULT_HOST
  });
  let broker = new mqtt.Server(handler);
  debug(': Instantiated local broker w/ opts:', opts);
  broker.listen(opts.port, opts.host, function () {
    let address = this.address();
    debug(': Local broker listening on %s:%s', address.address,
      address.port);
  });
  return broker;
}