How to use the multistream-select.Interactive function in multistream-select

To help you get started, we’ve selected a few multistream-select 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 / js-libp2p-switch / src / identify.js View on Github external
conn.dialStream(function (err, stream) {
      if (err) {
        return console.log(err)
      }
      var msi = new Interactive()
      msi.handle(stream, function () {
        msi.select('/ipfs/identify/1.0.0', function (err, ds) {
          if (err) { return console.log(err) }
          var identifyMsg = {}
          identifyMsg = {}
          identifyMsg.sender = exportPeer(peerSelf)
          // TODO (daviddias) populate with the way I see the other peer

          stream.write(JSON.stringify(identifyMsg))

          var answer = ''

          stream.on('data', function (chunk) {
            answer = answer + chunk.toString()
          })
github libp2p / js-libp2p-switch / src / swarm.js View on Github external
function multistreamHandshake (conn) {
      var msI = new multistream.Interactive()
      msI.handle(conn, function () {
        msI.select(protocol, callback)
      })
    }
  }

multistream-select

JavaScript implementation of multistream-select

MIT
Latest version published 3 years ago

Package Health Score

48 / 100
Full package analysis