tropo / PhonoSDK

Phono.com - The jQuery Phone API
http://phono.com
Other
131 stars 63 forks source link

Closing browser window doesn't "hang up" the current call #42

Open arielscarpinelli opened 10 years ago

arielscarpinelli commented 10 years ago

To reproduce:

Use the following code, set sip address to a sip address where you can actually receive a call:

    var call = null;
    var sipAddress = "sip:3366@login.zipdx.com";
    var phono = $.phono({
        apiKey : "C17D167F-09C6-4E4C-A3DD-2025D48BA243",
        onReady : function() {
            call = phono.phone.dial(sipAddress);
        },
    });

During the call, close the browser window. Bug: Notice that where you received the call, it is still active. It should had been hang up.

Workaround:

Based on this: http://chad.ill.ac/post/43030182362/strophe-js-disconnect-on-page-unload

    $(window).on('unload', function() {
        phono.connection.sync = true;
        if(call) call.hangup();
        phono.connection.flush();
        phono.connection.disconnect();        
    });