Skip to content

multiplex implementation wrapper that is compatible with libp2p Stream Muxer expected interface

License

Notifications You must be signed in to change notification settings

hackergrrl/js-libp2p-multiplex

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

js-libp2p-multiplex

Build Status Dependency Status js-standard-style

multiplex implementation wrapper that is compatible with libp2p Stream Muxer expected interface

Usage

Install

> npm i libp2p-multiplex

In tour code

const multiplex = require('libp2p-multiplex')

API

Attaching it to a socket (duplex stream)

As a listener

const listener = multiplex(socket, true)

As a dialer

const dialer = multiplex(socket, false)

Opening a multiplex duplex stream

const conn = dialer.newStream((err, conn) => {})

conn.on('error', (err) => {})

note: Works the same on the listener side

Receiving incoming stream

dialer.on('stream', (conn) => {})

note: Works the same on the listener side

Close

dialer.close()

note: Works the same on the listener side

Other events

dialer.on('close', () => {})
dialer.on('error', () => {})

note: Works the same on the listener side

About

multiplex implementation wrapper that is compatible with libp2p Stream Muxer expected interface

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%