How to use the libp2p-mplex.listener function in libp2p-mplex

To help you get started, we’ve selected a few libp2p-mplex examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github libp2p / go-libp2p-webrtc-direct / examples / standalone / index.js View on Github external
const listener = direct.createListener({ config: {} }, (conn) => {
    console.log('[listener] Got connection')

    const muxer = mplex.listener(conn)

    muxer.on('stream', (stream) => {
      console.log('[listener] Got stream')
      pull(
      stream,
      pull.drain((data) => {
        console.log('[listener] Received:')
        console.log(data.toString())
      })
      )
    })
  })
github RTradeLtd / Temporal / vendor / gx / ipfs / QmWGQQ6Tz8AdUpxktLf3zgnVN9Vy8fcWVezZJSU3ZmiANj / go-mplex / interop / js / server.js View on Github external
const listener = tcp.createServer((socket) => {
  let muxer = mplex.listener(toPull.duplex(socket))
  muxer.on('stream', (stream) => {
    readWrite(stream)
  })
  for (let i = 0; i < 100; i++) {
    muxer.newStream((err, stream) => {
      if (err) {
        throw err
      }
      readWrite(stream)
    })
  }
  socket.on('close', () => {
    listener.close()
  })
})

libp2p-mplex

JavaScript implementation of https://github.com/libp2p/mplex

MIT
Latest version published 3 years ago

Package Health Score

51 / 100
Full package analysis