holepunchto / hyperswarm

A distributed networking stack for connecting peers.
https://docs.holepunch.to
MIT License
1.06k stars 85 forks source link

get notified when a peer leaves topic? #22

Closed whatsdis closed 5 years ago

whatsdis commented 5 years ago

is there something like network().on('leave', (peer) => {//triggered whenever a peer leaves or disconnected});

RangerMauve commented 5 years ago

Listen for the close event on connections that get emitted inside the connection event.

E.g.

net.on('connection', (socket, details) => {
  console.log('new connection!', details)

  socket.once('close', () => {
    console.log('Lost peer')
  })
})