Skip to content

Commit

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

Socket.prototype.join = function(room){
debug('join room %s', room);
Socket.prototype.join = function(room, fn){
debug('joining room %s', room);
var self = this;
if (~this.joined.indexOf(room)) return this;
this.adapter.add(this.id, room, function(err){
if (err) return fn && fn(err);
debug('joined room %s', room);
self.joined.push(room);
fn && fn(null);
});
return this;
};

Expand Down

0 comments on commit 6046c38

Please sign in to comment.