onClose

The onClose event is fired when the socket is closed or if the server or client closes the server-side controller.

The example below will kill the connection after 5 seconds and then the onClose event on controller level will be triggered.

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

results matching ""

    No results matching ""