Team XSockets.NET

Lifetime Events

How to handle connection lifetime events

The events on connection level provide information about the socket being opened/closed. The controllers has their own lifetime events.


conn.onconnected = function(){
    console.log('socket connected');


conn.ondisconnected = function(){
    console.log('socket disconnected');

How to handle controller lifetime events

The controller has nothing to do with the actual socket. These events tell you about the controllers you are using over your connection.

OnOpen Event

conn.controller("chat").onopen = function(ci){

OnClose Event

conn.controller("chat").onclose = function(ci){

Open a controller

As soon as you start to communicate over a new controller the OnOpen event will fire. You actually do not need to specify the controller in the connection. As long as the controller exists on the server the OnOpen event will fire.

Close a controller

To close as controller (not the actual connection/socket) you just call the Close method on the controller instance. This will fire the OnClose event on the controller.


results matching ""

    No results matching ""