anternet-group

0.1.0 • Public • Published

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

Package Sidebar

Install

npm i anternet-group

Weekly Downloads

3

Version

0.1.0

License

MIT

Last publish

Collaborators

  • moshe