node.js - exports.* functions: getting other variables -
i have following code:
//app.js var ioroutes = require('./controllers/socket'); sio.sockets.on('connection', ioroutes.connection); //socket.js exports.connection = function(socket){ console.log('i have ' + socket); };
now, app.js can access sio object, want use see how many clients have connected. how can pass sio object exported 'connection' function?
thanks in advance.
you need add parameter connection function:
//app.js var ioroutes = require('./controllers/socket'); sio.sockets.on('connection', function(socket) { ioroutes.connection(socket, sio); }); //socket.js exports.connection = function(socket, sio){ console.log('i have ' + socket); };
Comments
Post a Comment