I am trying to get my hands on node ,reading through the book node.js in action ,I am came across this bit of code which is to be written on server side.
var socketio = require('socket.io');
socket.on('rooms', function() {
socket.emit('rooms', io.sockets.manager.rooms);
});
I am not sure how this works. As far as I understood the method socket.on()
registers/adds an event listener to listen to events of type rooms and then callbacks a function which emits a rooms event..?? is that how it works? its not making sense... when does the socket object emits rooms event?