sails.sockets.socketRooms( socket )

Purpose

Get the list of rooms a socket is subscribed to

Overview

Parameters

Description Accepted Data Types Required ?
1 Socket object Yes

Example Usage

  1. // Controller action
  2. getMyRooms: function(req, res) {
  3. var roomNames = JSON.stringify(sails.sockets.socketRooms(req.socket));
  4. res.json({
  5. message: 'I am subscribed to: '+roomNames
  6. });
  7. }

Notes

  • The phrase “request socket” here refers to an application-layer WebSocket/Socket.io connection. req.socket also exists for HTTP requests, but it refers to the underlying TCP socket at the transport layer, which is different. Be sure and ensure req.isSocket == true before using req.socket with this method.