Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function buildClient(done, callback) {
var client = mqtt.createConnection(settings.port, settings.host);
client.once('error', done);
client.stream.once('close', function() {
done();
});
client.on("connected", function() {
callback(client);
});
}
function buildClient(instance, done, callback) {
var client = mqtt.createConnection(instance.opts.port);
client.once('error', done);
client.stream.once('close', function() {
done();
});
client.on("connected", function() {
callback(client);
});
}
MQTTClient.prototype.connect = function(options) {
if (!this.connected) {
var self = this;
options = options||{};
self.options = options;
self.options.keepalive = options.keepalive||15;
self.options.clean = self.options.clean||true;
self.options.protocolId = 'MQIsdp';
self.options.protocolVersion = 3;
self.client = mqtt.createConnection(this.port,this.host,function(err,client) {
if (err) {
self.connected = false;
clearInterval(self.watchdog);
self.connectionError = true;
//util.log('[mqtt] ['+self.uid+'] connection error 1 : '+inspect(err));
self.emit('connectionlost',err);
return;
}
client.on('close',function(e) {
//util.log('[mqtt] ['+self.uid+'] on close');
clearInterval(self.watchdog);
if (!self.connectionError) {
if (self.connected) {
self.connected = false;
self.emit('connectionlost',e);
} else {
, next = function() {
if (receivers.length <= total) {
mqtt.createConnection(1883, '127.0.0.1', created);
}
};
, next = function() {
if (publishers.length < total) {
mqtt.createConnection(1883, '127.0.0.1', created);
}
};
, next = function() {
if (publishers.length < total) {
mqtt.createConnection(1883, '127.0.0.1', created);
}
};
, next = function() {
if (receivers.length <= total) {
mqtt.createConnection(1883, '127.0.0.1', created);
}
};
, next = function() {
if (receivers.length <= total) {
mqtt.createConnection(1883, '127.0.0.1', created);
}
};