-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add support for peer discovery to PeerManager and example of usage to…
… examples/
- Loading branch information
Gordon Hall
committed
Apr 19, 2014
1 parent
6e8589e
commit ba8542d
Showing
3 changed files
with
88 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
var PeerManager = require('../PeerManager'); | ||
var peerman = new PeerManager(); | ||
|
||
peerman.discoverPeers(function(err, peers) { | ||
// we get an array of peer instances | ||
console.log(peers); | ||
// the peer manager caches the tried seeds and any results | ||
console.log(peerman.seeds); | ||
// we can use this array of peers to add to the manager | ||
peers.forEach(function(p) { | ||
peerman.addPeer(p); | ||
}); | ||
// then we can start the manager | ||
peerman.start(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters