Compare commits

..

8 Commits
0.6 ... 0.6.2

Author SHA1 Message Date
Guillermo Rauch
054e818bd9 Fix spooky bug 2010-11-01 17:20:23 -03:00
Guillermo Rauch
107806b304 Bump version 2010-11-01 17:10:52 -03:00
Guillermo Rauch
426795395c Call onclose after destroying the connection 2010-11-01 17:10:13 -03:00
Guillermo Rauch
df929876de Updated package.json 2010-11-01 16:54:15 -03:00
Guillermo Rauch
1002105f7a added onClose skipDisconnect flag 2010-11-01 16:34:37 -03:00
Guillermo Rauch
8f4f82a413 onClose call 2010-11-01 15:35:52 -03:00
Guillermo Rauch
e1745e20ac Make sure to disconnect directly onClose if the client is not handshaked and he can't possibly reconnect 2010-11-01 15:35:06 -03:00
Guillermo Rauch
681f004fe9 Make sure to clear the FD on end 2010-11-01 15:01:24 -03:00
3 changed files with 16 additions and 12 deletions

View File

@@ -63,8 +63,9 @@ Client.prototype._onConnect = function(req, res){
this.connection = req.connection;
this.connection.addListener('end', function(){
self._onClose();
self.connection.end();
self.connection.destroy();
self._onClose();
});
if (req){
@@ -121,20 +122,25 @@ Client.prototype._onHeartbeat = function(h){
}
};
Client.prototype._onClose = function(){
Client.prototype._onClose = function(skipDisconnect){
if (this._open){
var self = this;
if ('_heartbeatInterval' in this) clearTimeout(this._heartbeatInterval);
if ('_heartbeatTimeout' in this) clearTimeout(this._heartbeatTimeout);
this._open = false;
this._disconnectTimeout = setTimeout(function(){
self._onDisconnect();
}, this.options.closeTimeout);
if (skipDisconnect !== false){
if (this.handshaked)
this._disconnectTimeout = setTimeout(function(){
self._onDisconnect();
}, this.options.closeTimeout);
else
this._onDisconnect();
}
}
};
Client.prototype._onDisconnect = function(){
if (this._open) this._onClose();
if (this._open) this._onClose(true);
if (this._disconnectTimeout) clearTimeout(this._disconnectTimeout);
if (this.connected){
this._writeQueue = [];

View File

@@ -19,7 +19,7 @@ WebSocket.prototype._onConnect = function(req, socket){
if (this.request.headers.upgrade !== 'WebSocket' || !this._verifyOrigin(this.request.headers.origin)){
this.listener.options.log('WebSocket connection invalid or Origin not verified');
this.connection.destroy();
this._onClose();
return false;
}
@@ -75,8 +75,7 @@ WebSocket.prototype._handle = function(data){
chunk = chunks[i];
if (chunk[0] !== '\u0000'){
this.listener.options.log('Data incorrectly framed by UA. Dropping connection');
this.connection.end();
this.connection.destroy();
this._onClose();
return false;
}
this._onMessage(chunk.slice(1));
@@ -99,9 +98,8 @@ WebSocket.prototype._proveReception = function(headers){
if (spaces === 0 || n % spaces !== 0){
if (this.listener && this.listener.options){
this.listener.options.log('Invalid WebSocket key: "' + k + '". Dropping connection');
this._onClose();
}
this.connection.end();
this.connection.destroy();
return false;
}

View File

@@ -1,6 +1,6 @@
{ "name" : "socket.io"
, "description" : "The cross-browser WebSocket"
, "version" : "0.6"
, "version" : "0.6.1"
, "author" : "LearnBoost"
, "licenses" :
[ { "type" : "MIT"