Sha256: fa672930c6d05a0b47846f0af006c07fb9b7be910a9caa30894c749b82ff07b0

Contents?: true

Size: 1.41 KB

Versions: 5

Compression:

Stored size: 1.41 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.
  **
***/
COMM.SessionWatcher = HApplication.extend({
  constructor: function( _timeoutSecs, _sesTimeoutValueId ){
    
    // onIdle is called when HSystem's ticker count % 100 == 0
    // this means it's 5 seconds with HSystemTickerInterval 50
    this.base(10, 'SesWatcher'); 
    
    // gets the HValue represented by
    // sesTimeoutValueId (:client_time in server)
    this.sesTimeoutValue = COMM.Values.values[_sesTimeoutValueId];
    this.timeoutSecs = _timeoutSecs;
  },
  
  // 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

5 entries across 5 versions & 1 rubygems

Version Path
rsence-2.0.0.10.pre js/comm/comm/sessionwatcher/sessionwatcher.js
rsence-2.0.0.9.pre js/comm/comm/sessionwatcher/sessionwatcher.js
rsence-2.0.0.8.pre js/comm/comm/sessionwatcher/sessionwatcher.js
rsence-2.0.0.7.pre js/comm/comm/sessionwatcher/sessionwatcher.js
rsence-2.0.0.6.pre js/comm/comm/sessionwatcher/sessionwatcher.js