node.js - SocketCluster - pass variable to emit event -
var socketcluster = require('socketcluster-client'); // ..... // ..... var scsocket = []; (var k = 0; k < 32; k++) { scsocket[k] = socketcluster.connect(options); scsocket[k].on('connect', function (status) { this.emit("auth", api_credentials, function (err, token) { console.log(k); // output 32 , exit process.exit(); }); }); } how can pass variable k emit function of scsocket client in right way : https://socketcluster.io/#!/docs/api-scsocket-client ?
Comments
Post a Comment