stephenlb / webrtc-sdk

WebRTC Simple Calling API + Mobile SDK - A simplified approach to RTCPeerConnection for mobile and web video calling apps.
https://stephenlb.github.io/webrtc-sdk/
MIT License
855 stars 278 forks source link

ended() not called on some disconnections #33

Closed js-beaulieu closed 5 years ago

js-beaulieu commented 7 years ago

> WebRTC Phone Auto Hangup and Goodbye on Unload

The WebRTC Calling SDK will attempt an automatic goodbye upon graceful disconnection attempts. This allows the 2nd party on the other end of the phone line to receive a call ended signal. This happens automatically.

I am facing an issue where sometimes the ended() callback isn't called for the third party on disconnection. I suspect this has to do with this... let's say ungraceful (?) disconnections... How would one go and detect such situations?

marvicrm commented 5 years ago

This happens to me sometimes. Thus, I had to put this code inside "session.connected" to make it works.

var pc = session.pc;
pc.oniceconnectionstatechange = function() {
      if(pc.iceConnectionState == 'disconnected') {                         
           session.hangup();                                    
        }
}
stephenlb commented 5 years ago

@marvicrm we'd love to accept your changes. would you submit a pull request? we can merge your fix into master.

stephenlb commented 5 years ago

added in webrtc-v2.js