diff --git a/index.js b/index.js index 38504cca..007e94f1 100644 --- a/index.js +++ b/index.js @@ -63,6 +63,10 @@ Adapter.prototype.del = function(id, room, fn){ this.rooms[room] = this.rooms[room] || {}; delete this.sids[id][room]; delete this.rooms[room][id]; + if (!this.rooms[room].length) { + delete this.rooms[room]; + } + if (fn) process.nextTick(fn.bind(null, null)); }; @@ -80,6 +84,10 @@ Adapter.prototype.delAll = function(id, fn){ if (rooms.hasOwnProperty(room)) { delete this.rooms[room][id]; } + + if (!this.rooms[room].length) { + delete this.rooms[room]; + } } } delete this.sids[id];