W3C home > Mailing lists > Public > public-webrtc-logs@w3.org > March 2020

Re: [webrtc-pc] Is close() supposed to fire state change events? Connection state change set asynchronously? (#1883)

From: Jan-Ivar Bruaroey via GitHub <sysbot+gh@w3.org>
Date: Wed, 11 Mar 2020 14:38:07 +0000
To: public-webrtc-logs@w3.org
Message-ID: <issue_comment.created-597672134-1583937486-sysbot+gh@w3.org>
> So, there is just no signalling telling me that the remote end hung up?

@eskimor There is. Either [use a datachannel](https://jsfiddle.net/jib1/m2gvhjtq/):
const dc1 = pc1.createDataChannel("dummy", {negotiated: true, id: 0});
const dc2 = pc2.createDataChannel("dummy", {negotiated: true, id: 0});
await Promise.all([dc1, dc2].map(dc => new Promise(r => dc.onopen = r)));
dc1.onclose = () => console.log("close fired"); // close fired
Works in Firefox and Chrome 82 (probably 80 as well, addIceCandidate errors look unrelated).
But not Safari. @youennf?

Had data channels always been included by default in WebRTC, then we could have done a simpler API for this, but they're not.

Or you can also [use the newer dtls transport object](https://jsfiddle.net/jib1/q4znf9b5/):
const {sender} = pc1.addTransceiver("audio");
await new Promise(r => pc1.onsignalingstatechange = r);
const {transport} = sender;
await new Promise(r => transport.onstatechange = () => transport.state == "connected"
                                                       && r());
transport.onstatechange = () => console.log(transport.state); // close
...which detects when the dtls connection drops, but that still only works in Chrome atm.

GitHub Notification of comment by jan-ivar
Please view or discuss this issue at https://github.com/w3c/webrtc-pc/issues/1883#issuecomment-597672134 using your GitHub account
Received on Wednesday, 11 March 2020 14:38:12 UTC

This archive was generated by hypermail 2.4.0 : Saturday, 6 May 2023 21:19:50 UTC