annotate node_modules/socket.io/lib/store.js @ 69:333afcfd3f3a

added node_modules to project and fixed path to chronometer also added deps to installer script
author tzara <rc-web@kiben.net>
date Sat, 26 Oct 2013 14:12:50 +0100
parents
children
rev   line source
rc-web@69 1
rc-web@69 2 /*!
rc-web@69 3 * socket.io-node
rc-web@69 4 * Copyright(c) 2011 LearnBoost <dev@learnboost.com>
rc-web@69 5 * MIT Licensed
rc-web@69 6 */
rc-web@69 7
rc-web@69 8 /**
rc-web@69 9 * Expose the constructor.
rc-web@69 10 */
rc-web@69 11
rc-web@69 12 exports = module.exports = Store;
rc-web@69 13
rc-web@69 14 /**
rc-web@69 15 * Module dependencies.
rc-web@69 16 */
rc-web@69 17
rc-web@69 18 var EventEmitter = process.EventEmitter;
rc-web@69 19
rc-web@69 20 /**
rc-web@69 21 * Store interface
rc-web@69 22 *
rc-web@69 23 * @api public
rc-web@69 24 */
rc-web@69 25
rc-web@69 26 function Store (options) {
rc-web@69 27 this.options = options;
rc-web@69 28 this.clients = {};
rc-web@69 29 };
rc-web@69 30
rc-web@69 31 /**
rc-web@69 32 * Inherit from EventEmitter.
rc-web@69 33 */
rc-web@69 34
rc-web@69 35 Store.prototype.__proto__ = EventEmitter.prototype;
rc-web@69 36
rc-web@69 37 /**
rc-web@69 38 * Initializes a client store
rc-web@69 39 *
rc-web@69 40 * @param {String} id
rc-web@69 41 * @api public
rc-web@69 42 */
rc-web@69 43
rc-web@69 44 Store.prototype.client = function (id) {
rc-web@69 45 if (!this.clients[id]) {
rc-web@69 46 this.clients[id] = new (this.constructor.Client)(this, id);
rc-web@69 47 }
rc-web@69 48
rc-web@69 49 return this.clients[id];
rc-web@69 50 };
rc-web@69 51
rc-web@69 52 /**
rc-web@69 53 * Destroys a client
rc-web@69 54 *
rc-web@69 55 * @api {String} sid
rc-web@69 56 * @param {Number} number of seconds to expire client data
rc-web@69 57 * @api private
rc-web@69 58 */
rc-web@69 59
rc-web@69 60 Store.prototype.destroyClient = function (id, expiration) {
rc-web@69 61 if (this.clients[id]) {
rc-web@69 62 this.clients[id].destroy(expiration);
rc-web@69 63 delete this.clients[id];
rc-web@69 64 }
rc-web@69 65
rc-web@69 66 return this;
rc-web@69 67 };
rc-web@69 68
rc-web@69 69 /**
rc-web@69 70 * Destroys the store
rc-web@69 71 *
rc-web@69 72 * @param {Number} number of seconds to expire client data
rc-web@69 73 * @api private
rc-web@69 74 */
rc-web@69 75
rc-web@69 76 Store.prototype.destroy = function (clientExpiration) {
rc-web@69 77 var keys = Object.keys(this.clients)
rc-web@69 78 , count = keys.length;
rc-web@69 79
rc-web@69 80 for (var i = 0, l = count; i < l; i++) {
rc-web@69 81 this.destroyClient(keys[i], clientExpiration);
rc-web@69 82 }
rc-web@69 83
rc-web@69 84 this.clients = {};
rc-web@69 85
rc-web@69 86 return this;
rc-web@69 87 };
rc-web@69 88
rc-web@69 89 /**
rc-web@69 90 * Client.
rc-web@69 91 *
rc-web@69 92 * @api public
rc-web@69 93 */
rc-web@69 94
rc-web@69 95 Store.Client = function (store, id) {
rc-web@69 96 this.store = store;
rc-web@69 97 this.id = id;
rc-web@69 98 };