Skip to content

Commit

Permalink
socket: added leave
Browse files Browse the repository at this point in the history
  • Loading branch information
rauchg committed Dec 24, 2012
1 parent 6046c38 commit ef96e3b
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/socket.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,20 @@ Socket.prototype.join = function(room, fn){
* Leaves a room.
*
* @param {String} room
* @param {Function} optional, callback
* @return {Socket} self
* @api private
*/

Socket.prototype.leave = function(room){
Socket.prototype.leave = function(room, fn){
debug('leave room %s', room);
var self = this;
this.adapter.del(this.id, room, function(err){
if (err) return fn && fn(err);
debug('left room %s', room);
self.joined.splice(self.joined.indexOf(room, 1));
fn && fn(null);
});
return this;
};

Expand Down

0 comments on commit ef96e3b

Please sign in to comment.