Skip to content

Commit

Permalink
example - unicast: upon new node discovery, send all known nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
wankdanker committed Oct 9, 2020
1 parent 9c5139e commit be1ac83
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions examples/unicast.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ d.on("added", node => {
, port : node.port
});

d.send('unicast-nodes', node);
//send all nodes that we know about to the network.
d.broadcast.destination.forEach(node => {
d.send('unicast-nodes', node);
});
}
});

Expand Down Expand Up @@ -76,4 +79,8 @@ d.join('unicast-nodes', node => {

d.on("error", err => {
console.log("error", err);
});
});

d.on('promotion', function () {
console.log('promoted');
})

0 comments on commit be1ac83

Please sign in to comment.