Handle Connect State Change

<String> LViS.ConnectionManager.ON_STATE

Fires when state has changed. Each state provides additional parameters:

  • LViS.ConnectionManager.STATE_DISCONNECTED does not expose any other parameters.

  • LViS.ConnectionManager.STATE_CONNECTING provides connect attempt and delay before the next attempt will occur.

  • LViS.ConnectionManager.STATE_CONNECTED provides correct server time.


// shorthand
var Connect = LViS.ConnectionManager;

Connect.bind(Connect.ON_STATE, function () {
    var state = arguments[0];
    switch (state) {
        case Connect.STATE_DISCONNECTED:
            // show disconnected method
        case Connect.STATE_CONNECTING:
            var attempt = arguments[1],
                delay = arguments[2];
            if (attempt >= 1) {
                // show connection bar
        case Connect.STATE_CONNECTED:
            var serverTime = arguments[1];
            // hide connection bar if it has been shown before