2.2.1 • Published 10 months ago

protomux-wakeup v2.2.1

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
10 months ago

protomux-wakeup

Wakeup protocol over protomux

npm install protomux-wakeup

Usage

const Wakeup = require('protomux-wakeup')

const w = new Wakeup()

w.addStream(stream)

const s = w.session(capability, {
  onpeeradd (peer) {
    // peer added
  },
  onpeerremove (peer) {
    // peer removed
  },
  onlookup (req, peer) {
    // received a lookup request
  },
  onannounce (wakeup, peer) {
    // received an announce message
  }
})

// the peers
s.peers

// request wakeup
s.lookup(peer, { hash })
s.announce(peer, [{ key, length }])

// or by stream
s.lookupByStream(stream, ...)
s.announceByStream(stream, ...)

// mark session as inactive, you must call this when done
s.inactive()

// cancel an inactive call
s.active()

// release the handlers
s.release()

License

Apache-2.0

2.2.1

10 months ago

2.2.0

10 months ago

2.1.0

10 months ago

2.0.2

10 months ago

2.0.1

10 months ago

2.0.0

10 months ago

1.1.1

10 months ago

1.1.0

10 months ago

1.0.3

10 months ago

1.0.2

10 months ago

1.0.1

10 months ago

1.0.0

10 months ago