Git Product home page Git Product logo

kad-webrtc's Introduction

UPDATE

npm run build-browser-e2e ./examples/webrtc-browser-e2e/server.js

Kad WebRTC Transport

A WebRTC transport adapter for Kad.

Setup

npm install [email protected] kad-webrtc

Usage

var Node = require('kad').Node;
var WebRTC = require('kad-webrtc');

var dht = new Node({
  // ...
  transport: WebRTC(WebRTC.Contact({ nick: 'mynickname' }), {
    signaller: SignalServer // see examples
  })
});

dht.connect({ nick: 'somebody' }, function(err) {
  console.log('party!');
});

Usage from Node

If you want to use this package from Node, or if you want to run the tests in this package, you will need to manually install the wrtc dependency.

You can do this by running:

npm install [email protected]

The reason for this is that the wrtc dependency doesn't install correctly on many platforms. So we leave it up to the user whether they want to include it or not.

Additionally, you will need to pass a reference to wrtc to the transport:

var Node = require('kad').Node;
var WebRTC = require('kad-webrtc');
var wrtc = require('wrtc');

var dht = new Node({
  // ...
  transport: WebRTC(WebRTC.Contact({ nick: 'mynickname' }), {
    wrtc: wrtc,
    signaller: SignalServer // see examples
  })
});

dht.connect({ nick: 'somebody' }, function(err) {
  console.log('party!');
});

Examples

To build the examples, run npm run build-examples.

After that, look at the READMEs in each example directory to see how to run them.

kad-webrtc's People

Contributors

omphalos avatar larryaubstore avatar

Watchers

James Cloos 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.