How can I listen to an event on the entire server and get the socket passed in on each call instead of having to generate and store new state data for every socket? Or is it not that expensive resource-wise?
io.on('connection', function(socket){
//do stuff here and make variables
console.log('a user connected');
socket.on('disconnect', function(){
console.log('user disconnected');
});
socket.on('message', function(){
console.log('user sent message', JSON.stringify(arguments,null,2));
//handle the message here.
});
});
Instead, I just want to do this:
io.on('message', function(socket){
console.log('io on message' , arguments);
});