holepunchto / hyperdht

The DHT powering Hyperswarm
https://docs.holepunch.to
MIT License
323 stars 46 forks source link

add a 'relaying' event to connections #184

Closed billiegoose closed 3 months ago

billiegoose commented 3 months ago

https://app.asana.com/0/1206774237110658/1207704548548702

Intent - there should be a .relay property on connection objects that accurately reflects the relaying state of the connection. And it should fire events when that state changes.

swarm.on('connection', (conn) => {
  function cb () {
    console.log('currently using relay?', conn.relay.relaying)
  }
  conn.relay.on('relay', cb)
  conn.relay.on('unrelay', cb)
}