0.1.0 • Published 8 years ago

anternet-group v0.1.0

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

anternet-group.js

build npm Join the chat at https://gitter.im/Anternet/anternet.js npm

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