line-mesh
line-mesh is a lightweight communication library that bears non-blocking interface and p2p scalable architecture. line-mesh is the cousin of line, they share very similar apis. line internally monitors connection health, and it pro-actively strives to achieve a stable connection.
line runs on Node.JS and all modern browsers through an identical API. Therefore, it is a good candidate for cross-platform applications.
Key Features
-
p2p: There is no server similar to bit-torrent, sopcast, popcorn-time
🔥 - Cross platform: Works on MacOS, Linux, Windows and browsers
- Developed in ES6 with Webpack, therefore we have a minified bundles that work nearly every platform without hassle
- Apart from netflux, we support message responses and request timeouts
- Easy configuring
- Promise based API
Installation
Using npm
npm install line-mesh --save
Usage
Simple Responder
const adapter = new LineMesh('line-mesh-req-res');
adapter.on('hello', request => {
console.log(`Event received from ${request.sender}`, request.payload);
request.resolve({yeppa: 'xxx'});
});
adapter.connect();
Simple Requester
const adapter = new LineMesh('line-mesh-req-res');
adapter.on(LineMesh.Event.MEMBER_JOINED, ({id}) => {
console.log(`New member with id=${id} joined network`);
adapter
.sendTo(id, 'hello', {foo: 'bar'})
.then(response => {
console.log('Got response', response);
});
});
adapter.connect();
Documentation
Extended documentation can be found here.
License
line-mesh by mertdogar is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.