Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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);