Skip to content

Commit

Permalink
socket: keep track of socket in connected hash
Browse files Browse the repository at this point in the history
  • Loading branch information
rauchg committed Dec 24, 2012
1 parent 2e71357 commit 95d8e75
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/socket.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ Socket.prototype.onconnect = function(){
debug('socket connected - writing packet');
this.join(this.id);
this.packet({ type: parser.CONNECT });
this.nsp.connected[this.id] = this;
};

/**
Expand Down Expand Up @@ -342,10 +343,12 @@ Socket.prototype.ondisconnect = function(){
Socket.prototype.onclose = function(reason){
if (!this.connected) return this;
debug('closing socket - reason %s', reason);
this.leaveAll();
this.nsp.remove(this);
this.client.remove(this);
this.connected = false;
this.disconnected = true;
delete this.nsp.connected[this.id];
this.emit('disconnect', reason);
};

Expand Down

0 comments on commit 95d8e75

Please sign in to comment.