[Freeswitch-users] Callback in Javascript, session.destroy() does not free the channel!
Michael Giagnocavo
mgg at giagnocavo.net
Thu Sep 17 15:08:48 PDT 2009
Dispose is a .NET only thing. But I think you are right - with anthm's changes, any way you kill your session, if you're on the right thread, it should really hangup.
-Michael
From: freeswitch-users-bounces at lists.freeswitch.org [mailto:freeswitch-users-bounces at lists.freeswitch.org] On Behalf Of Phillip Jones
Sent: Thursday, September 17, 2009 3:38 PM
To: freeswitch-users at lists.freeswitch.org
Subject: Re: [Freeswitch-users] Callback in Javascript, session.destroy() does not free the channel!
session.dispose();
???
On Thu, Sep 17, 2009 at 5:20 PM, Alberto Escudero <aep.lists at it46.se<mailto:aep.lists at it46.se>> wrote:
We are trying to create a callback application in Javascript. We get the
callerid from the unanswered call and after destroying the session, we
initiate a callback to the user to conenct it to a local extension in the
dialplan.
Although we have tried to destroy the first session, or even invoke a
second script using apiExecute("jsrun",dialer.js"), tried session.hangup()
or exit()... the first session does not seem to close properly until the
whole chain of scripts are completed.
Here is a piece of code that shows the concept (yes!, the sleep function
is far from ideal. CPU loves it! )
function sleep(milliseconds) {
var start = new Date().getTime();
for (var i = 0; i < 1e7; i++) {
if ((new Date().getTime() - start) > milliseconds){
break;
}
}
}
if (session.ready()) {
//We catch the caller_id
caller_id_num = session.caller_id_num;
console_log("Now we got your Caller ID\n");
//How long we want to wait to trigger a call back
session.execute("sleep",5000);
console_log("We have waited a while... time to create the
callback\n");
//apiExecute("jsrun", "callback.js");
}
//Destroy the session...
session.destroy();
session=undefined;
sleep(10000);
//Preparing callback
session2 = new
Session('{ignore_early_media=true}celliax/interface1/600464646');
session2.setAutoHangup(false);
session2.answer();
exit();
++
Wisdom thoughts?
--
Stopping junk mailers is good for the environment
_______________________________________________
FreeSWITCH-users mailing list
FreeSWITCH-users at lists.freeswitch.org<mailto:FreeSWITCH-users at lists.freeswitch.org>
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20090917/10af8c36/attachment-0002.html
More information about the FreeSWITCH-users
mailing list