Thursday, May 23, 2024
 Popular · Latest · Hot · Upcoming
140
rated 0 times [  147] [ 7]  / answers: 1 / hits: 17595  / 11 Years ago, mon, january 20, 2014, 12:00:00

I've been implementing a webrtc videochat.



Everything is working smoothly except for the case when the peer closes the browser.



I've been trying to handle this event by implementing an onended callback on the remote mediastream. Though, this callback does not seem to ever be called.



How can I detect that the peer's browser has been closed or that the connection was finished on the other side?


More From » html

 Answers
6

You can use the ICE connection status to determine this. If you disconnect one peer it takes some seconds (~5?) to recoginize it, but it works even without a signalling server.



(assuming you called your peer connection pc)



pc.oniceconnectionstatechange = function() {
if(pc.iceConnectionState == 'disconnected') {
console.log('Disconnected');
}
}

[#73057] Saturday, January 18, 2014, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
paola

Total Points: 675
Total Questions: 115
Total Answers: 95

Location: Laos
Member since Tue, Jul 7, 2020
4 Years ago
;