title: Sails.js + socket.io: Sending messages from server to clients
body: <p>I'm attempting to set up a system with sails.js to have the server broadcast messages to a set of clients. Basically:</p>
  
  <ol>
  <li>A client in Group A sends an AJAX request to the server.</li>
  <li>The server processes the request and sends a message through socket to all clients of Group B.</li>
  <li>The clients of Group B receive the message through the socket and display something.</li>
  </ol>
  
  <p>According to the socket.io documentation, I should be able to have the clients in Group B join a "room", and then have the server broadcast to that specific room, but on the client side, the preexisting "socket" doesn't have the method "socket.join('room')". So, I tried just sending a unique event to all clients:</p>
  
  <pre><code>socket.on("connect", function(){
    console.log("Client Connected");
  });
  
  socket.on("my_event", function(data){
    console.log("my_event received");
  });
  </code></pre>
  
  <p>This works fine by doing "sails.io.sockets.emit("my_event", {...})" on the server side, but isn't this sending the event to every single client? I could make the event name unique, something like "my_event_000" with an ID to specify the group, but that would still be sending events to every client unnecessarily. </p>
  
  <p>Should I be using "rooms"? And if so, how?</p>