socket.io get rooms which socket is currently in
Cross-compatible way
var rooms = Object.keys(io.sockets.adapter.sids[socket.id]);
// returns [socket.id, 'room-x'] or [socket.id, 'room-1', 'room-2', ..., 'room-x']
In socket.io version 1+ the syntax is:
socket.rooms