Skip to content

Commit

Permalink
Added events when emitting & receiving hello packets
Browse files Browse the repository at this point in the history
  • Loading branch information
Clément Bernardy committed May 19, 2016
1 parent 965653b commit 234bb37
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,12 @@ Triggered when a new node is not heard from within `nodeTimeout`
### master
Triggered when a new master has been selected

### helloReceived
Triggered when the node has received a hello from given one

### helloEmitted
Triggered when the node sends a hello packet


Node Object
-----------
Expand Down
3 changes: 3 additions & 0 deletions lib/discover.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ function Discover (options, callback) {
self.emit("added", node, obj, rinfo);
}

self.emit("helloReceived", node);

if (node.isMaster) {
//if we have this node and it was not previously a master then it is a new master node
if ((isNew || !wasMaster )) {
Expand Down Expand Up @@ -323,6 +325,7 @@ Discover.prototype.hello = function () {
var self = this;

self.broadcast.send("hello", self.me);
self.emit("helloEmitted");
};

Discover.prototype.advertise = function (obj) {
Expand Down

0 comments on commit 234bb37

Please sign in to comment.