View our GitHub

Please visit sails-docs on GitHub to view documentation on your mobile device.

Edit Page

sails.sockets.rooms()

Purpose

Get the list of all current socket rooms

Overview

Parameters

None.

Example Usage

// Controller action

getRoomsList: function(req, res) {
    var roomNames = JSON.stringify(sails.sockets.rooms());
    res.json({
      message: 'A list of all the rooms: '+roomNames
    });
}

Note: In Socket.io, all sockets are automatically subscribed to a global room with an empty name (''). This room is not returned as part of the array in sails.sockets.rooms

Is something missing?

If you notice something we've missed or could be improved on, please follow this link and submit a pull request to the sails-docs repo. Once we merge it, the changes will be reflected on the website the next time it is deployed.

Reference

We wrote a book!

Get early access to the book
with promotion code: mcneildoc

Get the Book