[Freeswitch-users] Callback in Javascript, session.destroy() does not free the channel!

Phillip Jones pjintheusa at gmail.com
Thu Sep 17 14:37:47 PDT 2009


session.dispose();

???

On Thu, Sep 17, 2009 at 5:20 PM, Alberto Escudero <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
> 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/dd92e4f2/attachment-0002.html 


More information about the FreeSWITCH-users mailing list