socket.io
Advanced tools
Comparing version 0.7.7 to 0.7.8
0.7.8 / 2011-08-08 | ||
================== | ||
* Changed; make sure sio#listen passes options to both HTTP server and socket.io manager. | ||
* Added docs for sio#listen. | ||
* Added options parameter support for Manager constructor. | ||
* Added memory leaks tests and test-leaks Makefile task. | ||
* Removed auto npm-linking from make test. | ||
* Make sure that you can disable heartbeats. [3rd-Eden] | ||
* Fixed rooms memory leak [3rd-Eden] | ||
* Send response once we got all POST data, not immediately [Pita] | ||
* Fixed onLeave behavior with missing clientsk [3rd-Eden] | ||
* Prevent duplicate references in rooms. | ||
* Added alias for `to` to `in` and `in` to `to`. | ||
* Fixed roomClients definition. | ||
* Removed dependency on redis for installation without npm [3rd-Eden] | ||
* Expose path and querystring in handshakeData [3rd-Eden] | ||
0.7.7 / 2011-07-12 | ||
@@ -3,0 +21,0 @@ ================== |
@@ -1,2 +0,1 @@ | ||
/*! | ||
@@ -12,5 +11,3 @@ * socket.io-node | ||
var http = require('http') | ||
, https = require('https') | ||
, fs = require('fs') | ||
var fs = require('fs') | ||
, url = require('url') | ||
@@ -59,3 +56,3 @@ , util = require('./util') | ||
function Manager (server) { | ||
function Manager (server, options) { | ||
this.server = server; | ||
@@ -88,2 +85,6 @@ this.namespaces = {}; | ||
for (var i in options) { | ||
this.settings[i] = options[i]; | ||
} | ||
this.initStore(); | ||
@@ -105,2 +106,9 @@ | ||
server.on('close', function () { | ||
clearInterval(self.gc); | ||
}); | ||
// run our private gc every 10 seconds | ||
this.gc = setInterval(this.garbageCollection.bind(this), 10000); | ||
for (var i in transports) { | ||
@@ -354,3 +362,3 @@ if (transports[i].init) { | ||
if (!this.roomClients[id]) { | ||
this.roomClients[id] = []; | ||
this.roomClients[id] = {}; | ||
} | ||
@@ -362,4 +370,6 @@ | ||
this.rooms[name].push(id); | ||
this.roomClients[id][name] = true; | ||
if (!~this.rooms[name].indexOf(id)) { | ||
this.rooms[name].push(id); | ||
this.roomClients[id][name] = true; | ||
} | ||
}; | ||
@@ -375,3 +385,11 @@ | ||
if (this.rooms[room]) { | ||
this.rooms[room].splice(this.rooms[room].indexOf(id), 1); | ||
var index = this.rooms[room].indexOf(id); | ||
if (index >= 0) { | ||
this.rooms[room].splice(index, 1); | ||
} | ||
if (!this.rooms[room].length) { | ||
delete this.rooms[room]; | ||
} | ||
delete this.roomClients[id][room]; | ||
@@ -435,4 +453,2 @@ } | ||
Manager.prototype.onClientDisconnect = function (id, reason) { | ||
this.onDisconnect(id); | ||
for (var name in this.namespaces) { | ||
@@ -443,2 +459,4 @@ if (this.roomClients[id][name]) { | ||
} | ||
this.onDisconnect(id); | ||
}; | ||
@@ -475,4 +493,5 @@ | ||
for (var room in this.roomClients[id]) { | ||
this.rooms[room].splice(this.rooms[room].indexOf(id), 1); | ||
this.onLeave(id, room); | ||
} | ||
delete this.roomClients[id] | ||
} | ||
@@ -594,5 +613,6 @@ | ||
var transport = new transports[data.transport](this, data, req); | ||
var transport = new transports[data.transport](this, data, req) | ||
, handshaken = this.handshaken[data.id]; | ||
if (this.handshaken[data.id]) { | ||
if (handshaken) { | ||
if (transport.open) { | ||
@@ -613,2 +633,7 @@ if (this.closed[data.id] && this.closed[data.id].length) { | ||
// flag as used | ||
delete handshaken.issued; | ||
this.onHandshake(data.id, handshaken); | ||
this.store.publish('handshake', data.id, handshaken); | ||
// initialize the socket for all namespaces | ||
@@ -788,3 +813,3 @@ for (var i in this.namespaces) { | ||
id | ||
, self.get('heartbeat timeout') || '' | ||
, self.enabled('heartbeats') ? self.get('heartbeat timeout') || '' : '' | ||
, self.get('close timeout') || '' | ||
@@ -822,3 +847,4 @@ , self.transports(data).join(',') | ||
var connection = data.request.connection | ||
, connectionAddress; | ||
, connectionAddress | ||
, date = new Date; | ||
@@ -840,5 +866,8 @@ if (connection.remoteAddress) { | ||
, address: connectionAddress | ||
, time: (new Date).toString() | ||
, time: date.toString() | ||
, query: data.query | ||
, url: data.request.url | ||
, xdomain: !!data.request.headers.origin | ||
, secure: data.request.connection.secure | ||
, issued: +date | ||
}; | ||
@@ -973,2 +1002,4 @@ }; | ||
* Declares a socket namespace | ||
* | ||
* @api public | ||
*/ | ||
@@ -983,1 +1014,24 @@ | ||
}; | ||
/** | ||
* Perform garbage collection on long living objects and properties that cannot | ||
* be removed automatically. | ||
* | ||
* @api private | ||
*/ | ||
Manager.prototype.garbageCollection = function () { | ||
// clean up unused handshakes | ||
var ids = Object.keys(this.handshaken) | ||
, i = ids.length | ||
, now = Date.now() | ||
, handshake; | ||
while (i--) { | ||
handshake = this.handshaken[ids[i]]; | ||
if ('issued' in handshake && (now - handshake.issued) >= 3E4) { | ||
this.onDisconnect(ids[i]); | ||
} | ||
} | ||
}; |
@@ -111,3 +111,3 @@ /** | ||
SocketNamespace.prototype.in = function (room) { | ||
SocketNamespace.prototype.in = SocketNamespace.prototype.to = function (room) { | ||
this.flags.endpoint = this.name + (room ? '/' + room : ''); | ||
@@ -231,2 +231,3 @@ return this; | ||
this.sockets[sid].onDisconnect(reason); | ||
delete this.sockets[sid]; | ||
} | ||
@@ -233,0 +234,0 @@ }; |
@@ -18,3 +18,3 @@ | ||
exports.version = '0.7.7'; | ||
exports.version = '0.7.8'; | ||
@@ -36,2 +36,5 @@ /** | ||
* | ||
* @param {HTTPServer/Number} a HTTP/S server or a port number to listen on. | ||
* @param {Object} opts to be passed to Manager and/or http server | ||
* @param {Function} callback if a port is supplied | ||
* @api public | ||
@@ -70,3 +73,3 @@ */ | ||
// otherwise assume a http/s server | ||
return new exports.Manager(server); | ||
return new exports.Manager(server, options); | ||
}; | ||
@@ -73,0 +76,0 @@ |
@@ -109,3 +109,3 @@ | ||
Socket.prototype.to = function (room) { | ||
Socket.prototype.to = Socket.prototype.in = function (room) { | ||
this.flags.room = room; | ||
@@ -112,0 +112,0 @@ return this; |
@@ -14,4 +14,3 @@ | ||
, Store = require('../store') | ||
, assert = require('assert') | ||
, redis = require('redis'); | ||
, assert = require('assert'); | ||
@@ -29,2 +28,3 @@ /** | ||
* - nodeId (fn) gets an id that uniquely identifies this node | ||
* - redis (fn) redis constructor, defaults to redis | ||
* - redisPub (object) options to pass to the pub redis client | ||
@@ -65,2 +65,4 @@ * - redisSub (object) options to pass to the sub redis client | ||
var redis = opts.redis || require('redis'); | ||
// initialize a pubsub client and a regular client | ||
@@ -67,0 +69,0 @@ this.pub = redis.createClient(opts.redisPub); |
@@ -262,3 +262,3 @@ | ||
Transport.prototype.setHeartbeatTimeout = function () { | ||
if (!this.heartbeatTimeout) { | ||
if (!this.heartbeatTimeout && this.manager.enabled('heartbeats')) { | ||
var self = this; | ||
@@ -283,3 +283,3 @@ | ||
Transport.prototype.clearHeartbeatTimeout = function () { | ||
if (this.heartbeatTimeout) { | ||
if (this.heartbeatTimeout && this.manager.enabled('heartbeats')) { | ||
clearTimeout(this.heartbeatTimeout); | ||
@@ -299,3 +299,3 @@ this.heartbeatTimeout = null; | ||
Transport.prototype.setHeartbeatInterval = function () { | ||
if (!this.heartbeatInterval) { | ||
if (!this.heartbeatInterval && this.manager.enabled('heartbeats')) { | ||
var self = this; | ||
@@ -404,3 +404,3 @@ | ||
Transport.prototype.clearHeartbeatInterval = function () { | ||
if (this.heartbeatInterval) { | ||
if (this.heartbeatInterval && this.manager.enabled('heartbeats')) { | ||
clearTimeout(this.heartbeatInterval); | ||
@@ -407,0 +407,0 @@ this.heartbeatInterval = null; |
@@ -57,2 +57,5 @@ | ||
req.on('end', function () { | ||
res.writeHead(200, headers); | ||
res.end('1'); | ||
self.onData(self.postEncoded ? qs.parse(buffer).d : buffer); | ||
@@ -69,5 +72,2 @@ }); | ||
} | ||
res.writeHead(200, headers); | ||
res.end('1'); | ||
} else { | ||
@@ -74,0 +74,0 @@ this.response = req.res; |
@@ -73,2 +73,3 @@ | ||
, 'Connection': 'Keep-Alive' | ||
, 'X-XSS-Protection': '0' | ||
}); | ||
@@ -75,0 +76,0 @@ |
{ | ||
"name": "socket.io" | ||
, "version": "0.7.7" | ||
, "version": "0.7.8" | ||
, "description": "Real-time apps made cross-browser & easy with a WebSocket-like API" | ||
@@ -18,5 +18,5 @@ , "homepage": "http://socket.io" | ||
, "dependencies": { | ||
"socket.io-client": "0.7.4" | ||
, "policyfile": "0.0.3" | ||
, "redis": "0.6.0" | ||
"socket.io-client": "0.7.5" | ||
, "policyfile": "0.0.4" | ||
, "redis": "0.6.6" | ||
} | ||
@@ -26,2 +26,3 @@ , "devDependencies": { | ||
, "should": "0.0.4" | ||
, "assertvanish": "0.0.3-1" | ||
} | ||
@@ -28,0 +29,0 @@ , "main": "index" |
@@ -23,3 +23,3 @@ # Socket.IO | ||
```js | ||
var app = express.createServer(); | ||
var app = express.createServer() | ||
, io = io.listen(app); | ||
@@ -26,0 +26,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 2 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
345374
68
11256
3
8
14
+ Addedpolicyfile@0.0.4(transitive)
+ Addedredis@0.6.6(transitive)
+ Addedsocket.io-client@0.7.5(transitive)
+ Addeduglify-js@1.0.6(transitive)
+ Addedwebsocket-client@1.0.0(transitive)
+ Addedxmlhttprequest@1.2.2(transitive)
- Removedpolicyfile@0.0.3(transitive)
- Removedredis@0.6.0(transitive)
- Removedsocket.io-client@0.7.4(transitive)
- Removeduglify-js@1.0.3(transitive)
Updatedpolicyfile@0.0.4
Updatedredis@0.6.6
Updatedsocket.io-client@0.7.5