Logging and Debugging

Socket.IO is now completely instrumented by a minimalistic yet tremendously powerful utility called debug by TJ Holowaychuk. Before 1.0, the Socket.IO server would default to logging everything out to the console. This turned out to be annoyingly verbose for many users (although extremely useful for others), so now we default to being completely silent by default. The basic idea is that each module used by Socket.IO provides different debugging scopes that give you insight into the internals. B

Manager#reconnectionDelayMax

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

Namespace#use

Namespace#use(fn:Function):Namespace Registers a middleware, which is a function that gets executed for every incoming Socket and receives as parameter the socket and a function to optionally defer execution to the next registered middleware. var io = require('socket.io')(); io.use(function(socket, next){ if (socket.request.headers.cookie) return next(); next(new Error('Authentication error')); }); Errors passed to middleware callbacks are sent as special error packets to clients.

Server#serveClient

Server#serveClient(v:Boolean):Server If v is true the attached server (see Server#attach) will serve the client files. Defaults to true. This method has no effect after attach is called. // pass a server and the `serveClient` option var io = require('socket.io')(http, { serveClient: false }); // or pass no server and then you can call the method var io = require('socket.io')(); io.serveClient(false); io.attach(http); If no arguments are supplied this method returns the current value.

Server#attach

Server#attach(srv:http#Server, opts:Object):Server Attaches the Server to an engine.io instance on srv with the supplied opts (optionally).

Client#conn

Client#conn A reference to the underlying engine.io Socket connection.

Manager

Manager(url:String, opts:Object) A Manager represents a connection to a given Socket.IO server. One or more Socket instances are associated with the manager. The manager can be accessed through the io property of each Socket instance. The opts are also passed to engine.io upon initialization of the underlying Socket. Options: – reconnection whether to reconnect automatically (true) – reconnectionDelay how long to wait before attempting a new reconnection (1000) – reconnectionDelayMax maximum am

IO#Emitter

IO#Emitter Reference to the Emitter constructor.

Server#use

Server#use See Namespace#use below.

Server#path

Server#path(v:String):Server Sets the path v under which engine.io and the static files will be served. Defaults to /socket.io. If no arguments are supplied this method returns the current value.