Sha256: e257c14aee3d576b58b667bcf5a69742b89ba086781e6e78aff8eb3c01369f7b

Contents?: true

Size: 1.43 KB

Versions: 8

Compression:

Stored size: 1.43 KB

Contents

/*   RSence
 *   Copyright 2009 Riassence Inc.
 *   http://riassence.com/
 *
 *   You should have received a copy of the GNU General Public License along
 *   with this software package. If not, contact licensing@riassence.com
 */


/*** = Description
  ** The single instance of this class is constructed after the first
  ** handshake request with the server by the 'main' plugin.
  **
  ** It has dual functionality:
  ** - It tells the the client time.
  **   It's available as the server HValue instance
  **   +msg.session[:main][:client_time]+ from
  **   any Plugin instance.
  ** - It polls the server on regular intervals.
  **   The polling interval is defined by the server
  **   as the _timeoutSecs constructor parameter.
  **
***/
//var//RSence.COMM
COMM.SessionWatcher = HApplication.extend({
  constructor: function( _timeoutSecs, _sesTimeoutValueId ){
    
    // gets the HValue represented by
    // sesTimeoutValueId (:client_time in server)
    this.sesTimeoutValue = COMM.Values.values[_sesTimeoutValueId];
    this.timeoutSecs = _timeoutSecs;
    
    // onIdle is called when HSystem's ticker count % 100 == 0
    // this means it's 5 seconds with HSystemTickerInterval 50
    this.base(10, 'SesWatcher'); 
    
  },
  
  // Tells the server the client's current time
  onIdle: function(){
    if((new Date().getTime() - this.sesTimeoutValue.value) > this.timeoutSecs ){
      this.sesTimeoutValue.set( new Date().getTime() );
    }
  }
});

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
rsence-2.1.9 js/comm/sessionwatcher/sessionwatcher.js
rsence-2.1.8 js/comm/sessionwatcher/sessionwatcher.js
rsence-pre-2.1.8.1 js/comm/sessionwatcher/sessionwatcher.js
rsence-pre-2.1.8.0 js/comm/sessionwatcher/sessionwatcher.js
rsence-2.1.7 js/comm/sessionwatcher/sessionwatcher.js
rsence-2.1.6 js/comm/sessionwatcher/sessionwatcher.js
rsence-2.1.5 js/comm/sessionwatcher/sessionwatcher.js
rsence-2.1.4 js/comm/sessionwatcher/sessionwatcher.js