Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/montyanderson/scatternet

A lightweight peer-to-peer network framework.
https://github.com/montyanderson/scatternet

javascript network node nodejs p2p socket udp

Last synced: 6 days ago
JSON representation

A lightweight peer-to-peer network framework.

Awesome Lists containing this project

README

        

# scatternet

A lightweight peer-to-peer network framework.

## Decentralised chat appliction example

``` javascript
const { Node } = require("scatternet");

const node = new Node("simplechat");

node.directory(6000, "public-directory-example.net");
node.listen();

node.on("message", ({ peer, msg }) => {
process.stdout.write(`\r${peer} - ${msg}`);
process.stdout.write("- ");
});

node.on("peer", peer => {
process.stdout.write(`\r${peer} joined the chat!\n`);
process.stdout.write("- ");
});

process.stdout.write("- ");

process.stdin.on("readable", () => {
const chunk = process.stdin.read();

if(chunk) {
process.stdout.write("- ");
node.broadcast(chunk);
}
});
```