onOpen

The onOpen event is fired when the controller instance has been instansiated on the server. The server will then send a onOpen event back to the client for the specific controller and the event will fire.

<script>
    var conn = new xsockets.client('ws://localhost:4502',['generic']);
    var generic = conn.controller('generic');
    generic.onOpen = function(ci){
        console.log('Generic controller open', ci);
    };
    conn.open();
</script>

If you pass in the controllers you want to use when you create the connection the controller(s) will be opened when the socket is opened.

// will open controller 'a' and 'b' directly
var conn = new xsockets.client('ws://localhost:4502',['a','b']);

If you do not pass in the controller when creating the connection they will be opened on first usage.

// will not open the controller 'a' until used
var conn = new xsockets.client('ws://localhost:4502');

//first usage of the controller will open it.
conn.controller('a')   

results matching ""

    No results matching ""