InnovateAsterisk / Browser-Phone

A fully featured browser based WebRTC SIP phone for Asterisk

Home Page:https://www.innovateasterisk.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Terminate call in jquery UI dialog

prathibhacdac opened this issue · comments

A call is initiaited between user A and user B. When user A clicks the close button in UI dialog, the call is not getting terminated. The call still continues in user B.

$(this).dialog("close") - only hides the iframe.

How to terminate the call on clicking the close button in dialog? How to call the cancelSession(lineNum)?

In the close event, I used this code:

close: function(event, ui) {
//$(this).dialog("close");
$(this).dialog("destroy").remove();
windowObj = null;
},

But it is still ringing on the receiver side.

I see there isn't great native handing for this, but because the frame only hides, the best you can try is to call Unregister(true);. This is typically what's called onbeforeunload.

If you really want to handle this correctly, first you would check if there are any active calls, and warn the user that they are about to end all the calls (if there are any), then iterate through the call(s), and terminate all of them, and then call the Unregister function.

How to call Unregister(true) from popup.html?

How to terminate the call?

Either call it directly:
window.frames[0].frameElement.contentWindow.Unregister(true);

or post a message:
https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage

or export the function

in phone.html

parent.CallUnregister = function() {
    Unregister(true);
}

then put this in the parent header of the parent window:

var CallUnregister = undefined;   //This must load before the IFRAME
function Unregister(){
      if(typeof CallUnregister != 'undefined'){
	      CallUnregister();
      } else {
	      console.error('The phone is not loaded yet,');
      }
}

Then just call Unregister() in the parent window.

I am always getting the message, The phone is not yet loaded. CallUnregister is never getting called. CallUnregister is always undefined.

window.frames[0].frameElement.contentWindow.Unregister(true); - This is also not working.

I have added some functionality that should demonstrate some of the functionality I think you need:

https://github.com/InnovateAsterisk/Browser-Phone/blob/master/Phone/popup.html

Thank you.