If the connection to the peer is disconnected with Peer.disconnect(), the close-event for DataConnections is not fired after one of the peers has gone.
This is tricky because the close event is currently best handled through the server, when a peer reports that it has left.
Currently DataChannel.onclose, the handler that is supposed to fire when the underlying transport is closed does not fire reliably. I will look into whether some of the other handlers (PeerConnection.oniceconnectionstatechange, PeerConnection.onreadystatechange, etc) would help with this.
Just looked into it. PeerConnection.oniceconnectionstatechange is the one to look at. I will make this change tonight.
Edit: this has a slight problem: it will only be effective when the PeerConnection is closed, so still won't solve the issue of no close when there are multiple DC.
oniceconnectionstatechange handler added, partially deals with #41 ex…
…cept for multiple DC
For the multiple DC case it might just be best at this point to catch DOM exceptions from sending on a closed DC and closing it from there. Need to think about this more though.
Anything new about this topic?
Nothing new from a native API standpoint. I'm currently on vacation so I'll be quite delayed in getting things done. If you think of a good solution please do make a pull request--I'll be checking those more often :).
Update: The DataChannel does close after something like 5-10 seconds. If there's a specific set of steps where you can get this to reproduce consistently feel free to reopen.