0.25.0 • Published 2 years ago

libp2p-webrtc-star v0.25.0

Weekly downloads
6,370
License
(Apache-2.0 OR MI...
Repository
github
Last release
2 years ago

js-libp2p-webrtc-star

npm.io npm.io npm.io Discourse posts npm.io npm.io Dependency Status js-standard-style

npm.io npm.io npm.io

libp2p WebRTC transport

Table of Contents

Description

libp2p-webrtc-star is one of the WebRTC transports available for libp2p.

Install

> npm install libp2p-webrtc-star

Usage

Using this module in Node.js (read: not in the browser)

To use this module in Node.js, you have to BYOI of WebRTC, there are multiple options out there, unfortunately, none of them are 100% solid. The ones we recommend are: wrtc and electron-webrtc.

Instead of just creating the WebRTCStar instance without arguments, you need to pass an options object with the WebRTC implementation:

const wrtc = require('wrtc')
const electronWebRTC = require('electron-webrtc')
const WStar = require('libp2p-webrtc-star')

// Using wrtc
const ws1 = new WStar({ wrtc: wrtc })

// Using electron-webrtc
const ws2 = new WStar({ wrtc: electronWebRTC() })

Using this module in the Browser

const WStar = require('libp2p-webrtc-star')
const multiaddr = require('multiaddr')
const all = require('it-all')

const addr = multiaddr('/ip4/188.166.203.82/tcp/20000/wss/p2p-webrtc-star/p2p/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSooo2a')

const ws = new WStar({ upgrader })

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

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

const socket = await ws.dial(addr)
const values = await all(socket)

console.log(`Value: ${values.toString()}`)

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

Signalling server

This module has an accompanying signalling server which is used to discover other peers running the libp2p-webrtc-star transport.

Please see the libp2p-webrtc-star-signalling-server module for more information.

API

Transport

npm.io

Connection

npm.io

Peer Discovery - ws.discovery

npm.io

0.25.0

2 years ago

0.24.1

2 years ago

0.24.0

3 years ago

0.23.0

3 years ago

0.22.4

3 years ago

0.22.3

3 years ago

0.22.2

3 years ago

0.22.1

3 years ago

0.22.0

3 years ago

0.21.2

3 years ago

0.21.1

3 years ago

0.21.0

3 years ago

0.20.8

3 years ago

0.20.7

3 years ago

0.20.6

3 years ago

0.20.5

3 years ago

0.20.4

3 years ago

0.20.3

3 years ago

0.20.2

3 years ago

0.20.1

4 years ago

0.20.0

4 years ago

0.19.0

4 years ago

0.18.6

4 years ago

0.18.5

4 years ago

0.18.4

4 years ago

0.17.11

4 years ago

0.18.3

4 years ago

0.18.1

4 years ago

0.17.10

4 years ago

0.18.0

4 years ago

0.17.9

4 years ago

0.17.8

4 years ago

0.17.7

4 years ago

0.17.6

4 years ago

0.17.5

4 years ago

0.17.4

4 years ago

0.17.3

4 years ago

0.17.2

4 years ago

0.17.1

4 years ago

0.17.0

5 years ago

0.16.1

5 years ago

0.16.0

5 years ago

0.15.8

5 years ago

0.15.7

5 years ago

0.15.6

5 years ago

0.15.5

6 years ago

0.15.4

6 years ago

0.15.3

6 years ago

0.15.1

6 years ago

0.15.2

6 years ago

0.15.0

6 years ago

0.14.0

6 years ago

0.13.4

6 years ago

0.13.3

6 years ago

0.13.2

7 years ago

0.13.1

7 years ago

0.13.0

7 years ago

0.12.0

7 years ago

0.11.0

7 years ago

0.10.1

7 years ago

0.10.0

7 years ago

0.9.0

7 years ago

0.8.10

7 years ago

0.8.8

7 years ago

0.8.7

7 years ago

0.8.6

7 years ago

0.8.5

7 years ago

0.8.4

7 years ago

0.8.3

7 years ago

0.8.1

7 years ago

0.8.0

7 years ago

0.7.5

7 years ago

0.7.4

7 years ago

0.7.3

7 years ago

0.7.2

7 years ago

0.7.1

7 years ago

0.7.0

7 years ago

0.6.1

7 years ago

0.6.0

7 years ago

0.5.0

8 years ago

0.4.5

8 years ago

0.4.4

8 years ago

0.4.3

8 years ago

0.4.1

8 years ago

0.4.0

8 years ago

0.3.2

8 years ago

0.3.1

8 years ago

0.3.0

8 years ago

0.2.3

8 years ago

0.2.2

8 years ago

0.2.1

8 years ago

0.2.0

8 years ago

0.1.4

8 years ago

0.1.3

8 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago