Migration from 0.9

For most applications, the transition to 1.0 should be completely seamless and devoid of any hiccups. That said, we’ve done some work to streamline some APIs, and we have changed some internals, so this is a recommended read for most existing users. Authentication differences Socket.io uses middleware now You can give a Socket.io server arbitrary functions via io.use() that are run when a socket is created. Check out this example: var srv = require('http').createServer(); var io = require('sock

Server

Server Exposed by require('socket.io').

Server#sockets

Server#sockets:Namespace The default (/) namespace.

Namespaces

Socket.IO allows you to “namespace” your sockets, which essentially means assigning different endpoints or paths. This is a useful feature to minimize the number of resources (TCP connections) and at the same time separate concerns within your application by introducing separation between communication channels. Default namespace We call the default namespace / and it’s the one Socket.IO clients connect to by default, and the one the server listens to by default. This namespace is identified by

Socket#request

Socket#request:Request A getter proxy that returns the reference to the request that originated the underlying engine.io Client. Useful for accessing request headers such as Cookie or User-Agent.

IO#Socket

IO#Socket Reference to the Socket constructor.

IO#Emitter

IO#Emitter Reference to the Emitter constructor.

Server#adapter

Server#adapter(v:Adapter):Server Sets the adapter v. Defaults to an instance of the Adapter that ships with socket.io which is memory based. See socket.io-adapter. If no arguments are supplied this method returns the current value.

Server#origins

Server#origins(v:String):Server Sets the allowed origins v. Defaults to any origins being allowed. If no arguments are supplied this method returns the current value.

Manager#timeout

Manager#timeout(v:Boolean):Manager Sets the timeout option, or returns it if no parameters are passed.