Sha256: d5953799a770f478ebfe2b0c5f20e7c1df843e36c6d90bd63dd7309d9c4f793f

Contents?: true

Size: 1.47 KB

Versions: 18

Compression:

Stored size: 1.47 KB

Contents

/*!
 * socket.io-node
 * Copyright(c) 2011 LearnBoost <dev@learnboost.com>
 * MIT Licensed
 */

/**
 * Expose the constructor.
 */

exports = module.exports = Store;

/**
 * Module dependencies.
 */

var EventEmitter = process.EventEmitter;

/**
 * Store interface
 *
 * @api public
 */

function Store (options) {
  this.options = options;
  this.clients = {};
};

/**
 * Inherit from EventEmitter.
 */

Store.prototype.__proto__ = EventEmitter.prototype;

/**
 * Initializes a client store
 *
 * @param {String} id
 * @api public
 */

Store.prototype.client = function (id) {
  if (!this.clients[id]) {
    this.clients[id] = new (this.constructor.Client)(this, id);
  }

  return this.clients[id];
};

/**
 * Destroys a client
 *
 * @api {String} sid
 * @param {Number} number of seconds to expire client data
 * @api private
 */

Store.prototype.destroyClient = function (id, expiration) {
  if (this.clients[id]) {
    this.clients[id].destroy(expiration);
    delete this.clients[id];
  }

  return this;
};

/**
 * Destroys the store
 *
 * @param {Number} number of seconds to expire client data
 * @api private
 */

Store.prototype.destroy = function (clientExpiration) {
  var keys = Object.keys(this.clients)
    , count = keys.length;

  for (var i = 0, l = count; i < l; i++) {
    this.destroyClient(keys[i], clientExpiration);
  }

  this.clients = {};

  return this;
};

/**
 * Client.
 *
 * @api public
 */

Store.Client = function (store, id) {
  this.store = store;
  this.id = id;
};

Version data entries

18 entries across 18 versions & 3 rubygems

Version Path
hooch-0.4.2 jasmine/node_modules/karma/node_modules/socket.io/lib/store.js
hooch-0.4.1 jasmine/node_modules/karma/node_modules/socket.io/lib/store.js
hooch-0.4.0 jasmine/node_modules/karma/node_modules/socket.io/lib/store.js
hooch-0.3.0 jasmine/node_modules/karma/node_modules/socket.io/lib/store.js
hooch-0.2.1 jasmine/node_modules/karma/node_modules/socket.io/lib/store.js
hooch-0.2.0 jasmine/node_modules/karma/node_modules/socket.io/lib/store.js
hooch-0.1.0 jasmine/node_modules/karma/node_modules/socket.io/lib/store.js
hooch-0.0.8 jasmine/node_modules/karma/node_modules/socket.io/lib/store.js
hooch-0.0.7 jasmine/node_modules/karma/node_modules/socket.io/lib/store.js
hooch-0.0.6 jasmine/node_modules/karma/node_modules/socket.io/lib/store.js
entangled-0.0.16 spec/dummy/public/node_modules/karma/node_modules/socket.io/lib/store.js
entangled-0.0.15 spec/dummy/public/node_modules/karma/node_modules/socket.io/lib/store.js
entangled-0.0.14 spec/dummy/public/node_modules/karma/node_modules/socket.io/lib/store.js
entangled-0.0.13 spec/dummy/public/node_modules/karma/node_modules/socket.io/lib/store.js
entangled-0.0.12 spec/dummy/public/node_modules/karma/node_modules/socket.io/lib/store.js
entangled-0.0.11 spec/dummy/public/node_modules/karma/node_modules/socket.io/lib/store.js
entangled-0.0.10 spec/dummy/public/node_modules/karma/node_modules/socket.io/lib/store.js
iron_worker_ng-0.10.1 iron_worker_examples/binary/phantom-nodejs/node_modules/phantom/node_modules/dnode/node_modules/socket.io/lib/store.js