Skip to content

P2P overlay network designed for the Web platform (browsers)

Notifications You must be signed in to change notification settings

areiter/webrtc-explorer

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

83 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

webrtc-explorer

tl;dr webrtc-explorer is a Chord inspired P2P overlay network designed for the Web platform (browsers), using WebRTC as its transport between peers and WebSockets for Signaling data. Essentially, it enables your peers (browsers) to communicate between each other without the need to have a server as a mediator of messages.

Badgers

NPM

![Gitter](https://badges.gitter.im/Join Chat.svg) Dependency Status

Properties

  • Ids have 48 bits (so that is a multiple of 4 (for hex notation) and doesn't require importing a big-num lib to handle over 53 bits operations)
  • The number of fingers of each peer is flexible, however it is recommended to not pass 16 per node (due to browser resource constraints)
  • Each peer is responsible for a segment of the hash ring
  • The signaling server for webrtc-explorer can be found at: https://github.com/diasdavid/webrtc-explorer-signalling-server

Usage

webrtc-explorer uses browserify

Create a new peer

var Explorer = require('webrtc-explorer');

var config = {
    signalingURL: 'https://url-to-webrtc-ring-signaling-server.com'
};
var peer = new Explorer(config);

peer.events.on('ready', function () {
    // this node is ready
});

Register the peer

peer.events.on('registered', function(data){
    // peer registered with data.peerId
});

peer.register();

Send and receive a message

peerIds are 48 bits represented in a string using hex format. To send, in one peer:

var data = 'hey peer, how is it going';

peer.send('abcd0f0fdbca', data);

To receive, in another peer (responsible for that Id)

peer.events.on('message', function(envelope){
    // message from the other peer envelope.data
});

Other options

logging

add the logging flag to your config

var config = {
    //...
    logging: true
};

How does it work

To understand fully webrtc-explorer's core, it is crucial to be familiar with the Chord. webrtc-explorer levarages important battle experience from building webrtc-ring - https://blog.daviddias.me/2014/12/20/webrtc-ring

  • I'll upload my notes and images soon, I'm trying to make them as legible as possible. If you have a urgency in one of the parts, please let me know, so that I put that one as a priority.

Registering a peer

Updating the finger table

Signaling between two peers

Message routing

About

P2P overlay network designed for the Web platform (browsers)

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%