Mercurial > hg > nodescore
comparison node_modules/socket.io/lib/transports/http-polling.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 * Module requirements. | |
10 */ | |
11 | |
12 var HTTPTransport = require('./http'); | |
13 | |
14 /** | |
15 * Exports the constructor. | |
16 */ | |
17 | |
18 exports = module.exports = HTTPPolling; | |
19 | |
20 /** | |
21 * HTTP polling constructor. | |
22 * | |
23 * @api public. | |
24 */ | |
25 | |
26 function HTTPPolling (mng, data, req) { | |
27 HTTPTransport.call(this, mng, data, req); | |
28 }; | |
29 | |
30 /** | |
31 * Inherits from HTTPTransport. | |
32 * | |
33 * @api public. | |
34 */ | |
35 | |
36 HTTPPolling.prototype.__proto__ = HTTPTransport.prototype; | |
37 | |
38 /** | |
39 * Transport name | |
40 * | |
41 * @api public | |
42 */ | |
43 | |
44 HTTPPolling.prototype.name = 'httppolling'; | |
45 | |
46 /** | |
47 * Override setHandlers | |
48 * | |
49 * @api private | |
50 */ | |
51 | |
52 HTTPPolling.prototype.setHandlers = function () { | |
53 HTTPTransport.prototype.setHandlers.call(this); | |
54 this.socket.removeListener('end', this.bound.end); | |
55 this.socket.removeListener('close', this.bound.close); | |
56 }; | |
57 | |
58 /** | |
59 * Removes heartbeat timeouts for polling. | |
60 */ | |
61 | |
62 HTTPPolling.prototype.setHeartbeatInterval = function () { | |
63 return this; | |
64 }; | |
65 | |
66 /** | |
67 * Handles a request | |
68 * | |
69 * @api private | |
70 */ | |
71 | |
72 HTTPPolling.prototype.handleRequest = function (req) { | |
73 HTTPTransport.prototype.handleRequest.call(this, req); | |
74 | |
75 if (req.method == 'GET') { | |
76 var self = this; | |
77 | |
78 this.pollTimeout = setTimeout(function () { | |
79 self.packet({ type: 'noop' }); | |
80 self.log.debug(self.name + ' closed due to exceeded duration'); | |
81 }, this.manager.get('polling duration') * 1000); | |
82 | |
83 this.log.debug('setting poll timeout'); | |
84 } | |
85 }; | |
86 | |
87 /** | |
88 * Clears polling timeout | |
89 * | |
90 * @api private | |
91 */ | |
92 | |
93 HTTPPolling.prototype.clearPollTimeout = function () { | |
94 if (this.pollTimeout) { | |
95 clearTimeout(this.pollTimeout); | |
96 this.pollTimeout = null; | |
97 this.log.debug('clearing poll timeout'); | |
98 } | |
99 | |
100 return this; | |
101 }; | |
102 | |
103 /** | |
104 * Override clear timeouts to clear the poll timeout | |
105 * | |
106 * @api private | |
107 */ | |
108 | |
109 HTTPPolling.prototype.clearTimeouts = function () { | |
110 HTTPTransport.prototype.clearTimeouts.call(this); | |
111 | |
112 this.clearPollTimeout(); | |
113 }; | |
114 | |
115 /** | |
116 * doWrite to clear poll timeout | |
117 * | |
118 * @api private | |
119 */ | |
120 | |
121 HTTPPolling.prototype.doWrite = function () { | |
122 this.clearPollTimeout(); | |
123 }; | |
124 | |
125 /** | |
126 * Performs a write. | |
127 * | |
128 * @api private. | |
129 */ | |
130 | |
131 HTTPPolling.prototype.write = function (data, close) { | |
132 this.doWrite(data); | |
133 this.response.end(); | |
134 this.onClose(); | |
135 }; | |
136 | |
137 /** | |
138 * Override end. | |
139 * | |
140 * @api private | |
141 */ | |
142 | |
143 HTTPPolling.prototype.end = function (reason) { | |
144 this.clearPollTimeout(); | |
145 return HTTPTransport.prototype.end.call(this, reason); | |
146 }; | |
147 |