Sails exposes several methods (
sails.sockets.*) which provide a simple interface for realtime communication with connected socket clients. This is useful for pushing events and data to connected clients in realtime, rather than waiting for them to actively request it using HTTP. This is true regardless of whether a client sockets was connected from a browser tab, from an iOS app, or even from 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, a higher level abstraction which 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.