Example #1
0
PresenceManager.prototype.addClient = function (clientSessionId, userId, userType,
  userData, clientData, callback) {
  if (typeof clientData === 'function') {
    callback = clientData
  }

  var message = {
    userId: userId,
    userType: userType,
    userData: userData,
    clientId: clientSessionId,
    online: true,
    sentry: this.sentry.name
  }

  if (clientData) { message.clientData = clientData }

  // We might need the details before we actually do a store.add
  this.store.cacheAdd(clientSessionId, message)

  Persistence.persistHash(this.scope, userId + '.' + clientSessionId, message)

  if (this.policy && this.policy.maxPersistence) {
    Persistence.expire(this.scope, this.policy.maxPersistence)
  }

  Persistence.publish(this.scope, message, callback)
}
Example #2
0
Status.prototype._set = function(scope, message, policy, callback) {
  Persistence.persistHash(scope, message.key, message.value);
  if(policy && policy.maxPersistence) {
    Persistence.expire(scope, policy.maxPersistence);
  } else {
    logger.warn('resource created without ttl :', scope);
    logger.warn('resource policy was :', policy);
  }
  Persistence.publish(scope, message, callback);
};
Example #3
0
Sentry.prototype.publishKeepAlive = function(options) {
  options = options || {};
  var name = options.name || this.name; //publish on behalf of someone else
  var expiration = options.expiration || Date.now() + Sentry.expiry;  //custom expiry
  var message = {
    name: name,
    alive: true,
    host: os.hostname,
    expiration: expiration
  };
  this.sentries[name] = message;

  if(options.save === false) return; /*specific check*/

  Persistence.persistHash(Sentry.channel, this.name, message);
  Persistence.publish(Sentry.channel, message);
};
Example #4
0
PresenceManager.prototype.addClient = function(clientId, userId, userType, userData, callback) {
  var message = {
    userId: userId,
    userType: userType,
    userData: userData,
    clientId: clientId,
    online: true,
    sentry: this.sentry.name
  };

  this.stampExpiration(message);

  //we might need the details before we actually do a store.add
  this.store.cacheAdd(clientId, message);

  Persistence.persistHash(this.scope, userId + '.' + clientId, message);

  if(this.policy && this.policy.maxPersistence) {
    Persistence.expire(this.scope, this.policy.maxPersistence);
  }

  Persistence.publish(this.scope, message, callback);
};