.getId()Parse the socket ID from an incoming socket request (req).
sails.sockets.getId(req);
| Argument | Type | Details | |
|---|---|---|---|
| 1 | req | A socket request (req). | 
Once acquired, the socket object's ID can be used to send direct messages to that socket (see sails.sockets.broadcast).
// Controller action
getSocketID: function(req, res) {
  if (!req.isSocket) {
    return res.badRequest();
  }
  var socketId = sails.sockets.getId(req);
  // => "BetX2G-2889Bg22xi-jy"
  sails.log('My socket ID is: ' + socketId);
  return res.json(socketId);
}
- Be sure to check that
 req.isSocket === truebefore passing inreq. This method does not work for HTTP requests!