Skip to content

Commit

Permalink
socket: fix emit
Browse files Browse the repository at this point in the history
  • Loading branch information
rauchg committed Dec 24, 2012
1 parent de8e746 commit eb02138
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions lib/socket.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,20 @@ Socket.prototype.emit = function(ev){
packet.id = this.nsp.ids++;
}

// dispatch packet
this.packet(packet);
if (this.rooms || (this.flags && this.flags.broadcast)) {
this.adapter.broadcast(packet, {
except: [this.id],
rooms: this.rooms,
flags: this.flags
});
} else {
// dispatch packet
this.packet(packet);
}

// reset flags
if (this.flags.length) this.flags = [];
if (this.rooms.lenth) this.rooms = [];
delete this.rooms;
delete this.flags;
}
return this;
};
Expand Down

0 comments on commit eb02138

Please sign in to comment.