Closed cvan closed 10 years ago
My memory is a bit fuzzy, but I think the docs are correct. The 'close' event is fired by peer nodes themselves, whereas the 'disconnection' event is fired by the P object itself (so you can listen for disconnection of nodes even if you don't have a handle on the objects).
https://github.com/oztu/p/blob/master/lib/P.js#L44 :
peer.on('close', function(){
peers.remove(peer);
});
The close event is literally the webrtc datachannel close event, so it gets that event object as the callback argument for listeners, whereas the 'disconnection' event provides the peer object as the callback argument for listeners.
The close
event on the peer
was never firing. Turns out this is why:
It looks like your code is doing the right thing. Now that I know this is why, it might be good to make mention of it in P's docs. Thanks for your help.
Per the API in the README:
Per
P.js
:Should the docs say
disconnection
- or am I mistaken?