mirror of
https://github.com/fluencelabs/js-libp2p-websockets
synced 2025-04-24 19:02:30 +00:00
Bumps [abortable-iterator](https://github.com/alanshaw/abortable-iterator) from 2.1.0 to 3.0.0. - [Release notes](https://github.com/alanshaw/abortable-iterator/releases) - [Commits](https://github.com/alanshaw/abortable-iterator/compare/v2.1.0...v3.0.0) Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
js-libp2p-websockets
JavaScript implementation of the WebSockets module that libp2p uses and that implements the interface-transport interface
Lead Maintainer
Description
libp2p-websockets
is the WebSockets implementation compatible with libp2p.
Usage
Install
npm
> npm i libp2p-websockets
Example
const WS = require('libp2p-websockets')
const multiaddr = require('multiaddr')
const pipe = require('it-pipe')
const { collect } = require('streaming-iterables')
const addr = multiaddr('/ip4/0.0.0.0/tcp/9090/ws')
const ws = new WS({ 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 pipe(
socket,
collect
)
console.log(`Value: ${values.toString()}`)
// Close connection after reading
await listener.close()
API
Transport
Connection
Description
Languages
JavaScript
100%