Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
src
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

js-libp2p-webrtc-direct

Discourse posts Dependency Status js-standard-style

A WebRTC transport built for libp2p (not mandatory to use with libp2p) that doesn't require the set up a signalling server. Caveat, you can only establish Browser to Node.js and Node.js to Node.js connections.

Lead Maintainer

Vasco Santos.

Table of Contents

Install

npm

> npm install libp2p-webrtc-direct

Usage

const WebRTCDirect = require('libp2p-webrtc-direct')
const multiaddr = require('multiaddr')
const pipe = require('pull-stream')
const { collect } = require('streaming-iterables')

const addr = multiaddr('/ip4/127.0.0.1/tcp/9090/http/p2p-webrtc-direct')

const webRTCDirect = new WebRTCDirect()

const listener = webRTCDirect.createListener((socket) => {
  console.log('new connection opened')
  pipe(
    ['hello'],
    socket
  )
})

await listener.listen(addr)
console.log('listening')

const conn = await webRTCDirect.dial(addr)
const values = await pipe(
  conn,
  collect
)
console.log(`Value: ${values.toString()}`)

// Close connection after reading
await listener.close()

Outputs:

listening
new connection opened
Value: hello

Note that it may take some time for the connection to be established.

API

Transport

Connection

Contribute

The libp2p implementation in JavaScript is a work in progress. As such, there are a few things you can do right now to help out:

  • Go through the modules and check out existing issues. This would be especially useful for modules in active development. Some knowledge of IPFS/libp2p may be required, as well as the infrastructure behind it - for instance, you may need to read up on p2p and more complex operations like muxing to be able to help technically.
  • Perform code reviews.
  • Add tests. There can never be enough tests.

License

MIT © Protocol Labs

About

Dial using WebRTC without the need to set up any Signalling Rendezvous Point!

Resources

License

Packages

No packages published
You can’t perform that action at this time.