diff --git a/lib/namespace.js b/lib/namespace.js index 639e4b1bb5..4524b4bff1 100644 --- a/lib/namespace.js +++ b/lib/namespace.js @@ -114,14 +114,17 @@ Namespace.prototype.run = function(socket, fn){ }; /** - * Targets a room. + * Targets a room when emitting. * - * @api private + * @param {String} name + * @return {Namespace} self + * @api public */ Namespace.prototype.to = -Namespace.prototype.in = function(fn){ - this.rooms.push(fn); +Namespace.prototype.in = function(name){ + this.rooms = this.rooms || []; + if (!~this.rooms.indexOf(name)) this.rooms.push(name); return this; };