Sails exposes several methods (
sails.sockets.*) that provide a simple interface for realtime communication with connected socket clients. These are useful for pushing events and data to connected clients in realtime, rather than waiting for their HTTP requests. These methods are available regardless of whether a client socket was connected from a browser tab, an iOS app, or your favorite household IoT appliance.
These methods are implemented using a built-in instance of Socket.IO, which is available directly as
sails.io. However, you should almost never use
sails.io directly. Instead, you should call the methods available on
sails.sockets.*. In addition, for certain use cases, you might also want to take advantage of resourceful PubSub methods, which access a higher level of abstraction and are used by Sails' built-in blueprint API.
||Subscribe all members of a room to one or more additional rooms.|
||Broadcast a message to all sockets connected to the server.|
||Broadcast a message to all sockets in a room.|
||Parse the socket ID from an incoming socket request (
||Subscribe a socket to a room.|
||Unsubscribe a socket from a room.|
||Unsubscribe all members of one room from that room and from every other room they are currently subscribed to, except the automatic room with the same name as each socket ID.|
||Unsubscribe all members of a room from one or more other rooms.|
Don't see a method you're looking for above? A number of
sails.socketsmethods were deprecated in Sails v0.12, either because a more performant alias was already available, or for performance and scalability reasons. Please see the v0.12 migration guide for more information.