How to use the mqtt-packet.connection function in mqtt-packet

To help you get started, we’ve selected a few mqtt-packet 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 mqttjs / MQTT.js / lib / connection.js View on Github external
var mqttPacket = require('mqtt-packet')
  , Connection = mqttPacket.connection
  , inherits   = require('inherits');

function emitPacket(packet) {
  this.emit(packet.cmd, packet);
}

function MQTTConnection(duplex, opts) {
  if (!(this instanceof MQTTConnection)) {
    return new MQTTConnection(duplex, opts);
  }

  Connection.call(this, duplex, opts);

  this.stream = duplex;

  this.on('data', emitPacket);

mqtt-packet

Parse and generate MQTT packets like a breeze

MIT
Latest version published 5 days ago

Package Health Score

84 / 100
Full package analysis