javascript – get rooms and connected sockets


there is a code like this:

var static = require('node-static');
var http = require('http');
var file = new(static.Server)();
var app = http.createServer(function (req, res) {
    file.serve(req, res);

var io = require('').listen(app);

io.sockets.on('connection', function (socket) {
    socket.on('room', function (room ) { = room;
    socket.join(;'room', room);

how to get data about rooms?


you can get rooms like this: let rooms = Object.keys(socket.rooms);

Scroll to Top