I am making an app with node.js(express)+socket.io and I am wondering how I can use the socket object which is the parameter of io.on('connection',function(socket){... from outside like routes files in the routes folder
app.js
app.get('/foo/:id?', routes.foo);
routes/foo.js
exports.index = function(req, res){
//do something with socket such as socket.join()
};
any ideas or tips would be appreciated.
edited
My goal is to let a user who accesses '/foo/:id?' join the socket.io's room(https://github.com/LearnBoost/socket.io/wiki/Rooms) named id?'.
So I would like to call socket.join('req.params.id') at
exports.index = function(req, res){
//HERE
};
Socketviareq.connection.SocketI'm talking about is the parameter ofsocket.io's callback.I've peeked what req.connection have though I coudln't see anything related to socket.io in it or am I missing something?socketobject. Not sure what is available for socket.io, sorry.