multiplex implementation wrapper that is compatible with libp2p Stream Muxer expected interface
> npm i libp2p-multiplex
const multiplex = require('libp2p-multiplex')
As a listener
const listener = multiplex(socket, true)
As a dialer
const dialer = multiplex(socket, false)
const conn = dialer.newStream((err, conn) => {})
conn.on('error', (err) => {})
note: Works the same on the listener side
dialer.on('stream', (conn) => {})
note: Works the same on the listener side
dialer.close()
note: Works the same on the listener side
dialer.on('close', () => {})
dialer.on('error', () => {})
note: Works the same on the listener side