This section describes the methods available on each SailsSocket instance. Most of these methods can be called before the socket even connects to the server. In the case of request methods like
.request(), calls will be queued up until the socket connects, at which time they will be executed in order.
The most common methods you will use with a SailsSocket instance are documented in the main Socket Client reference section. These include
In addition to the basic communication and event-listening methods, each SailsSocket instance (including
io.socket) exposes several methods for dealing with server connections.
Determines whether the SailsSocket instance is currently connected to a server; returns
true if a connection has been established.
Determines whether the SailsSocket instance is currently in the process of connecting to a server; returns
true if a connection is being attempted.
Detects when the SailsSocket instance has already loaded but is not yet fully configured or has not attempted to autoconnect.
sails.io.js library waits one tick of the event loop before checking whether
autoConnect is enabled and, if so, trying to connect. This allows you to configure the
SailsSocket instance (for example, by setting
io.sails.url) before an attempt is made to estabilish a connection. The
mightBeAboutToAutoConnect() method returns
true in the situation where
sails.io.js has loaded, but the requisite tick of the event loop has not yet elapsed.
Disconnects a SailsSocket instance from the server; throws an error if the socket is already disconnected.
Reconnects a SailsSocket instance to a server after it's been disconnected (either involuntarily or via a call to
.disconnect()). The instance connects using its currently configured properties.
.reconnect() throws an error if the socket is already connected to a server.
When an instance is in a disconnected state, its properties may be changed. This means that an instance that has been disconnected from one server can be reconnected to another without losing its event bindings or queued requests.
Stops listening for any server-related events on a SailsSocket instance, including