Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
dstClient.on("connect", () => {
const srcParser = mqtt.parser(opts);
const dstParser = mqtt.parser(opts);
// const noopParser = mqtt.parser(opts);
//
// noopParser.on('packet', (packet) => {
// logger.log('debug', "packet event emitted on noopParser", {packet: packet});
// });
//
// noopParser.on('error', (error) => {
// logger.log('debug', "error event emitted on noopParser", {errorMessage: error.message});
// });
srcClient.on('data', (data) => {
logger.log('debug', "srcClient has data", {data: data});
try {
srcParser.parse(data);
} catch (err) {
logger.log('error', "Parse error in srcParser", {errorName: err.name, errorMessage: err.message});
function Client (broker, conn, req) {
var that = this
this.broker = broker
this.conn = conn
this.req = req
this.parser = mqtt.parser()
this.connected = false
this.connackSent = false
this.errored = false
this.clean = true
this._handling = 0
this.subscriptions = {}
this.id = null
// we use two variables for the will
// because we store in _will while
// we are authenticating
this.will = null
this._will = null
conn.client = this
dstClient.on("connect", () => {
const srcParser = mqtt.parser(opts);
const dstParser = mqtt.parser(opts);
// const noopParser = mqtt.parser(opts);
//
// noopParser.on('packet', (packet) => {
// logger.log('debug', "packet event emitted on noopParser", {packet: packet});
// });
//
// noopParser.on('error', (error) => {
// logger.log('debug', "error event emitted on noopParser", {errorMessage: error.message});
// });
srcClient.on('data', (data) => {
logger.log('debug', "srcClient has data", {data: data});
try {
srcParser.parse(data);
} catch (err) {
MqttClient.prototype._setupStream = function () {
var connectPacket,
that = this,
writable = new Writable(),
parser = mqttPacket.parser(this.options),
completeParse = null,
packets = [];
this._clearReconnect();
this.stream = this.streamBuilder(this);
parser.on('packet', function (packet) {
packets.push(packet);
});
function process () {
var packet = packets.shift(),
done = completeParse;
if (packet) {
that._handlePacket(packet, process);
function createParser (opts) {
that.parser = build(opts)
that.parser.on('packet', push)
that.parser.on('error', that.stream.emit.bind(that.stream, 'error'))
}
constructor(stack, stream) {
super();
let self = this;
this.stack = stack;
this.stream = stream;
this._parser = mqtt.parser();
this._workload = 1;
this._dead = false;
this.stack.install(this);
stream.on('readable', self._work.bind(self));
stream.on('error', this.emit.bind(this, 'error'));
stream.on('close', this.emit.bind(this, 'close'));
this._parser.on('packet', function (packet) {
self._workload++;
stack.process(self, packet, self._work.bind(self));
});
this._parser.on('error', this.emit.bind(this, 'error'));
MqttClient.prototype._setupStream = function () {
var connectPacket
var that = this
var writable = new Writable()
var parser = mqttPacket.parser(this.options)
var completeParse = null
var packets = []
this._clearReconnect()
this.stream = this.streamBuilder(this)
parser.on('packet', function (packet) {
packets.push(packet)
})
function nextTickWork () {
if (packets.length) {
process.nextTick(work)
} else {
var done = completeParse
MqttClient.prototype._setupStream = function () {
var connectPacket
var that = this
var writable = new Writable()
var parser = mqttPacket.parser(this.options)
var completeParse = null
var packets = []
this._clearReconnect()
this.stream = this.streamBuilder(this)
parser.on('packet', function (packet) {
packets.push(packet)
})
function process () {
var packet = packets.shift()
var done = completeParse
if (packet) {