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