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: [email protected] 
[mailto:[email protected]] On Behalf Of Phillip 
Jones
Sent: Thursday, September 17, 2009 3:38 PM
To: [email protected]
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 
<[email protected]<mailto:[email protected]>> 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
[email protected]<mailto:[email protected]>
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org

_______________________________________________
FreeSWITCH-users mailing list
[email protected]
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org

Reply via email to