Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,13 @@ Client.prototype.setup = function(){

Client.prototype.connect = function(name){
debug('connecting to namespace %s', name);
if (!this.server.nsps[name]) {
var nsp = this.server.nsps[name];

if (!nsp) {
this.packet({ type: parser.ERROR, nsp: name, data : 'Invalid namespace'});
return;
}
var nsp = this.server.of(name);

if ('/' != name && !this.nsps['/']) {
this.connectBuffer.push(name);
return;
Expand Down
13 changes: 7 additions & 6 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -363,16 +363,17 @@ Server.prototype.close = function(){

['on', 'to', 'in', 'use', 'emit', 'send', 'write', 'clients', 'compress'].forEach(function(fn){
Server.prototype[fn] = function(){
var nsp = this.sockets[fn];
return nsp.apply(this.sockets, arguments);
return this.sockets[fn].apply(this.sockets, arguments);
};
});

Namespace.flags.forEach(function(flag){
Server.prototype.__defineGetter__(flag, function(){
this.sockets.flags = this.sockets.flags || {};
this.sockets.flags[flag] = true;
return this;
Object.defineProperty(Server.prototype, flag, {
get: function() {
this.sockets.flags = this.sockets.flags || {};
this.sockets.flags[flag] = true;
return this;
}
});
});

Expand Down
12 changes: 7 additions & 5 deletions lib/namespace.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,12 @@ Namespace.prototype.__proto__ = Emitter.prototype;
*/

exports.flags.forEach(function(flag){
Namespace.prototype.__defineGetter__(flag, function(){
this.flags = this.flags || {};
this.flags[flag] = true;
return this;
Object.defineProperty(Namespace.prototype, flag, {
get: function() {
this.flags = this.flags || {};
this.flags[flag] = true;
return this;
}
});
});

Expand Down Expand Up @@ -138,7 +140,7 @@ Namespace.prototype.run = function(socket, fn){
*/

Namespace.prototype.to =
Namespace.prototype['in'] = function(name){
Namespace.prototype.in = function(name){
this.rooms = this.rooms || [];
if (!~this.rooms.indexOf(name)) this.rooms.push(name);
return this;
Expand Down
16 changes: 10 additions & 6 deletions lib/socket.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,12 @@ Socket.prototype.__proto__ = Emitter.prototype;
*/

flags.forEach(function(flag){
Socket.prototype.__defineGetter__(flag, function(){
this.flags = this.flags || {};
this.flags[flag] = true;
return this;
Object.defineProperty(Socket.prototype, flag, {
get: function() {
this.flags = this.flags || {};
this.flags[flag] = true;
return this;
}
});
});

Expand All @@ -94,8 +96,10 @@ flags.forEach(function(flag){
* @api public
*/

Socket.prototype.__defineGetter__('request', function(){
return this.conn.request;
Object.defineProperty(Socket.prototype, 'request', {
get: function() {
return this.conn.request;
}
});

/**
Expand Down