Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

rename "emit" to "trigger" to prevent messing up socket.io

to bad! would be nice to have emit
  • Loading branch information...
commit 01ac63e6810259db43537382c8ce7505f8fdebda 1 parent fd59a5a
@tj authored
Showing with 5 additions and 4 deletions.
  1. +5 −4 lib/cluster-live.js
View
9 lib/cluster-live.js
@@ -53,6 +53,7 @@ function live(port, host, options) {
// maintain array of clients
var len = sockets.push(sock);
sock.id = len - 1;
+
sock.on('disconnect', function(){
sockets.splice(sock.id, 1);
});
@@ -64,7 +65,7 @@ function live(port, host, options) {
// "emit" an event
- sock.emit = function(){
+ sock.trigger = function(){
this.send({
type: 'event'
, args: utils.toArray(arguments)
@@ -72,12 +73,12 @@ function live(port, host, options) {
};
// emit "master change" to initialize master data
- sock.emit('master change', stripMaster(master));
+ sock.trigger('master change', stripMaster(master));
// emit "worker change" event to initialize
// all worker charts on connection
master.children.forEach(function(worker){
- sock.emit('worker change', stripWorker(worker));
+ sock.trigger('worker change', stripWorker(worker));
});
});
@@ -85,7 +86,7 @@ function live(port, host, options) {
sockets.emit = function(event){
for (var i = 0, len = sockets.length; i < len; ++i) {
- sockets[i].emit.apply(sockets[i], arguments);
+ sockets[i].trigger.apply(sockets[i], arguments);
}
};
Please sign in to comment.
Something went wrong with that request. Please try again.