session.dispose();<br><br>???<br><br><div class="gmail_quote">On Thu, Sep 17, 2009 at 5:20 PM, Alberto Escudero <span dir="ltr"><<a href="mailto:aep.lists@it46.se">aep.lists@it46.se</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
We are trying to create a callback application in Javascript. We get the<br>
callerid from the unanswered call and after destroying the session, we<br>
initiate a callback to the user to conenct it to a local extension in the<br>
dialplan.<br>
<br>
Although we have tried to destroy the first session, or even invoke a<br>
second script using apiExecute("jsrun",dialer.js"), tried session.hangup()<br>
or exit()... the first session does not seem to close properly until the<br>
whole chain of scripts are completed.<br>
<br>
Here is a piece of code that shows the concept (yes!, the sleep function<br>
is far from ideal. CPU loves it! )<br>
<br>
function sleep(milliseconds) {<br>
var start = new Date().getTime();<br>
for (var i = 0; i < 1e7; i++) {<br>
if ((new Date().getTime() - start) > milliseconds){<br>
break;<br>
}<br>
}<br>
}<br>
<br>
if (session.ready()) {<br>
//We catch the caller_id<br>
caller_id_num = session.caller_id_num;<br>
<br>
console_log("Now we got your Caller ID\n");<br>
<br>
//How long we want to wait to trigger a call back<br>
session.execute("sleep",5000);<br>
<br>
console_log("We have waited a while... time to create the<br>
callback\n");<br>
<br>
//apiExecute("jsrun", "callback.js");<br>
}<br>
<br>
//Destroy the session...<br>
session.destroy();<br>
session=undefined;<br>
<br>
sleep(10000);<br>
<br>
//Preparing callback<br>
session2 = new<br>
Session('{ignore_early_media=true}celliax/interface1/600464646');<br>
session2.setAutoHangup(false);<br>
session2.answer();<br>
exit();<br>
<br>
++<br>
Wisdom thoughts?<br>
<br>
--<br>
Stopping junk mailers is good for the environment<br>
<br>
<br>
<br>
<br>
_______________________________________________<br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
</blockquote></div><br>