anternet-group
v0.1.0
Published
Anternet library for join and get other peers based on a group id.
Downloads
12
Readme
anternet-group.js
Anternet library for join and get other peers based on a group id.
Example
const Anternet = require('anternet');
const Group = require('anternet-group');
const id = '<< hash >>';
const anternet = new Anternet();
const group = new Group(anternet, id);
// other peer address
const address = '127.0.0.1';
const port = 12345;
group.add(port, address);
console.log(group.size); // 1
// update and find more peers
group.update();
group.on('update', (found) => {
console.log('peers found: ', found);
});
// get peers from other peer
group.get(port, address, (err, peers) => {
if (err) throw err;
peer.forEach(peer => console.log(`${peer.address}:${peer.port}`));
});
License
MIT License. Copyright © 2016 Moshe Simantov