Skip to content

Commit

Permalink
Simplify and clarify.
Browse files Browse the repository at this point in the history
  • Loading branch information
Manuel Baclet committed Jun 11, 2015
1 parent 55274af commit bac5b0e
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions index.js
Expand Up @@ -60,11 +60,10 @@ Adapter.prototype.add = function(id, room, fn){

Adapter.prototype.del = function(id, room, fn){
this.sids[id] = this.sids[id] || {};
this.rooms[room] = this.rooms[room] || Room();
delete this.sids[id][room];
this.rooms[room].del(id);
if (this.rooms[room].length === 0) {
delete this.rooms[room];
if (this.rooms.hasOwnProperty(room)) {
this.rooms[room].del(id);
if (this.rooms[room].length === 0) delete this.rooms[room];
}

if (fn) process.nextTick(fn.bind(null, null));
Expand All @@ -84,9 +83,7 @@ Adapter.prototype.delAll = function(id, fn){
for (var room in rooms) {
if (this.rooms.hasOwnProperty(room)) {
this.rooms[room].del(id);
}
if (this.rooms[room].length === 0) {
delete this.rooms[room];
if (this.rooms[room].length === 0) delete this.rooms[room];
}
}
}
Expand Down

0 comments on commit bac5b0e

Please sign in to comment.