anternet
v0.3.1
Published
A framework of libraries based on UDP protocol for peer-to-peer communications.
Downloads
13
Readme
anternet.js
Anternet is a framework of libraries based on UDP protocol for peer-to-peer communications.
Libraries
- anternet-channel - Listening to broadcasts form other peers
- anternet-broadcast - Broadcast to other peers that listening on given channel
- shared-vars - Share variables between two or more endpoints
More libraries is on the way..
Example
const Anternet = require('anternet');
const msgType = 1; // can be any positive number
const address = '127.0.0.1';
const port = 12345;
// peer 1
const anternet1 = new Anternet();
anternet1.bind(port);
anternet1.on(msgType, (rid, args, rinfo) => {
anternet1.response(rid, args.reverse(), rinfo.port, rinfo.address);
});
// peer 2
const anternet2 = new Anternet();
anternet2.request(msgType, ['foo', 'bar'], port, address, (err, args, rinfo) => {
console.log(args); // [ "bar", "foo" ]
});
License
MIT License. Copyright © 2016 Moshe Simantov