toy-peers
Simple network for Peer-To-Peer simulations which provides all mechanisms to build a low-level peer-to-peer network.
toy-peers
relies on websockets to connect peers and exchange messages. Handshakes and offers are performed using Json Web Tokens.
Installation
npm install toy-peers --save
Getting started
Let's create a simple network with two peers connected to each other.
const Peer = Peer; // peerA will run on port 80801, and peerB on port 8081const peerA = 8080;const peerB = 8081; // launch peerspeerA;peerB; // listen for messages received from other peerspeerA; peerB; // connect peerA and peerB and then send a messagepeerA;
Documentation
Generate JSDoc documentation in doc/
directory with the following command
npm run doc
Testing
# run tests with Mocha + Chai npm test # compute code coverage with istanbul npm run coverage