Giter Site home page Giter Site logo

webrtc-explorer's Introduction

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: 'http://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 - http://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

webrtc-explorer's People

Contributors

daviddias avatar reggi avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.