io.sails object is the home of global configuration options for the
sails.io.js library, as well as any sockets it creates. Most of the properties on
io.sails are used as settings when connecting a client socket to the server, or as top-level configuration for the client library itself.
io.sails also provides a
.connect() method used for creating new socket connections manually.
See Socket Client for information about your different options for configuring
false, or if you need to create more than one socket connection with the
sails.io.js library, you do so via
io.sails.connect([url], [options]). Both arguments are optional, and the value of the
io.sails properties (like
transports, etc.) are used as defaults. See the SailsSocket properties reference for options.
io.sails.autoConnect is set to
true (the default), the library will wait one cycle of the event loop after loading and then attempt to create a new
SailsSocket and connect it to the URL specified by
io.sails.url. When used in the browser, the new socket will be exposed as
io.socket. When used in a Node.js script, the new socket will be attached as the
socket property of the variable used to initialize the
io.sails.environment to set an environment for
sails.io.js, which affects how much information is logged to the console. Valid values are
development (full logs) and
production (minimal logs).
The other properties of
io.sails are used as defaults when creating new sockets (either the eager socket or via
io.sails.connect()). See the SailsSocket properties reference for a full list of available options, as well as a table of the default
io.sails values. Here are the most commonly used properties:
||The URL that the socket is connected to, or will attempt to connect to.|
||The transports that the socket will attempt to connect using. Transports will be tried in order, with upgrades allowed: that is, if you list both "polling" and "websocket", then after establishing a long-polling connection the server will attempt to upgrade it to a websocket connection. This setting should match the value of
||Dictionary of headers to be sent by default with every request from this socket. Can be overridden via the