client.js
function () {
        var self = this;
        self.activity = false;

        if (self.heartBeat) {
            clearTimeout(self.heartBeat);
        }

        self.heartBeat = setTimeout(function () {
            if (self.state == 'live') {
                if (self.activity) {
                    console.log('Server session ready to expire, activity detected, keeping alive');
                    self.pingSession(); // Will setup new timer
                }
                else if (self.controller.clientExpire && this.controller.clientExpire()) {    // See if expiration handled by controller
                    console.log('Server session ready to expire, controller resetting itself to be offline');

                    return; // No new timer
                }
                else {
                    console.log('Server session ready to expire, resetting controller to be offline');
                    self.expireController();
                }
            }
        }, self.sessionExpiration - self.sessionExpirationCushion);
    }
function () {
        var self = this;
        self.activity = false;

        if (self.heartBeat) {
            clearTimeout(self.heartBeat);
        }

        self.heartBeat = setTimeout(function () {
            if (self.state == 'live') {
                if (self.activity) {
                    console.log('Server session ready to expire, activity detected, keeping alive');
                    self.pingSession(); // Will setup new timer
                }
                else if (self.controller.clientExpire && this.controller.clientExpire()) {    // See if expiration handled by controller
                    console.log('Server session ready to expire, controller resetting itself to be offline');

                    return; // No new timer
                }
                else {
                    console.log('Server session ready to expire, resetting controller to be offline');
                    self.expireController();
                }
            }
        }, self.sessionExpiration - self.sessionExpirationCushion);
    }
function ( ) { var self = this ; self . activity = false ; if ( self . heartBeat ) { clearTimeout ( self . heartBeat ) ; } self . heartBeat = setTimeout ( function ( ) { if ( self . state == 'live' ) { if ( self . activity ) { console . log ( 'Server session ready to expire, activity detected, keeping alive' ) ; self . pingSession ( ) ; // Will setup new timer } else if ( self . controller . clientExpire && this . controller . clientExpire ( ) ) { // See if expiration handled by controller console . log ( 'Server session ready to expire, controller resetting itself to be offline' ) ; return ; // No new timer } else { console . log ( 'Server session ready to expire, resetting controller to be offline' ) ; self . expireController ( ) ; } } } , self . sessionExpiration - self . sessionExpirationCushion ) ; }
Manage session expiration by listening for 'activity' and pinging the
the server just before the session expires
Manage session expiration by listening for activity and pinging the the server just before the session expires