[Freeswitch-users] How to track call changes while running javascript?

Thomas lists at virtues.net
Fri Aug 7 22:28:32 MSD 2015


Answering my own question for the record and the search engines:

Prequesites were:
- Block call progress during ringing until Javascript finishes
- Be able to register and act upon hangups from the a-leg
- Script should only execute once, not a second time for the b-leg

These things seem to vary between the different execute_* options. The one that does exactly what we needed was 
execute_on_pre_answer. That will run only once on the a-leg, will not proceed until JS terminates, and enables both 
hangupHook and session.ready.


On 05.08.2015 14:56, Thomas wrote:
> It looks like the problem is the JS running before the call gets bridged. Is there any way to register a hangup in JS 
> before bridging?
>
> Since that JS is part of the call setup, it has to run before the bridge. :/
>
> On 04.08.2015 11:49, Thomas wrote:
>> It's regular JS sleeps blocking, but I tried the sleep dialplan app (from JS), too - same thing. I tried 
>> session.ready but it does not change if the SIP leg hangs up. The whole process establishes the call, so it 
>> terminates once that is done, it's the actual dialing process through a socket on another device. But the socket 
>> isn't blocking. That was my first guess and I worked around it.
>>
>>
>> On 02.08.2015 18:11, Michael Jerris wrote:
>>> what is it blocking on in the js?  are you using session.ready?
>>>
>>> On Sunday, August 2, 2015, Thomas <lists at virtues.net <mailto:lists at virtues.net>> wrote:
>>>
>>>     They both don't change/fire. :/ It's as if the JS blocks everything about that call until it terminates. The
>>>     hangup does
>>>     not even register in the Freeswitch log until after the script finishes. Tried it outside execute_on_originate
>>>     with the
>>>     normal javascript application in the XML dialplan - same effect. The whole process seems to be a single thread -
>>>     which
>>>     would make sense for most use cases, unfortunately just not this one. :P
>>>
>>>     Is there a way to fork the JS execution into the background? Something similar to setTimout() maybe? Or even better
>>>     execute a dialplan app from JS that allows outside events to catch up? I tried the sleep application instead of JS
>>>     msleep, but that didn't help either.
>>>
>>>     On 01.08.2015 22:05, Ken Rice wrote:
>>>     > You are looking for session ready or a hanguk up hook callback see confluence for details
>>>     >
>>>     > Sent from my iPhone
>>>     >
>>>     >> On Aug 1, 2015, at 3:53 PM, Thomas <lists at virtues.net> wrote:
>>>     >>
>>>     >> Does anyone know if there is a way to track changes to the call state, most notably a hangup, while executing
>>>     >> Javascript? We're using JS to set up a call on a device connected to Freeswitch through portaudio. That call is
>>>     >> initiated with sip/sofia executing the JS in the dialplan. If the SIP leg hangs up while the JS is running,
>>>     nothing
>>>     >> happens until the JS terminates.
>>>     >>
>>>     >> I wanted to check from the script, but haven't found a way to do that. "session.state" doesn't change, hangup
>>>     hook
>>>     >> doesn't fire, and without setTimeout or something similar I didn't find a way to "background" the JS.
>>>     >>
>>>     >> Is there any way to detect a hangup during JS execution?
>>>     >>
>>>     >> Cheers!
>>>     >>
>>>     >> Thomas
>>>     >>
>>>     >>
>>>     >> _________________________________________________________________________
>>>     >> Professional FreeSWITCH Consulting Services:
>>>     >> consulting at freeswitch.org <javascript:;>
>>>     >> http://www.freeswitchsolutions.com
>>>     >>
>>>     >> Official FreeSWITCH Sites
>>>     >> http://www.freeswitch.org
>>>     >> http://confluence.freeswitch.org
>>>     >> http://www.cluecon.com
>>>     >>
>>>     >> FreeSWITCH-users mailing list
>>>     >> FreeSWITCH-users at lists.freeswitch.org <javascript:;>
>>>     >> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
>>>     >> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
>>>     >> http://www.freeswitch.org
>>>
>>>
>>>     _________________________________________________________________________
>>>     Professional FreeSWITCH Consulting Services:
>>>     consulting at freeswitch.org <javascript:;>
>>>     http://www.freeswitchsolutions.com
>>>
>>>     Official FreeSWITCH Sites
>>>     http://www.freeswitch.org
>>>     http://confluence.freeswitch.org
>>>     http://www.cluecon.com
>>>
>>>     FreeSWITCH-users mailing list
>>>     FreeSWITCH-users at lists.freeswitch.org <javascript:;>
>>>     http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
>>>     UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
>>>     http://www.freeswitch.org
>>>
>>>
>>>
>>> _________________________________________________________________________
>>> Professional FreeSWITCH Consulting Services:
>>> consulting at freeswitch.org
>>> http://www.freeswitchsolutions.com
>>>
>>> Official FreeSWITCH Sites
>>> http://www.freeswitch.org
>>> http://confluence.freeswitch.org
>>> http://www.cluecon.com
>>>
>>> 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
>>
>>
>>
>> _________________________________________________________________________
>> Professional FreeSWITCH Consulting Services:
>> consulting at freeswitch.org
>> http://www.freeswitchsolutions.com
>>
>> Official FreeSWITCH Sites
>> http://www.freeswitch.org
>> http://confluence.freeswitch.org
>> http://www.cluecon.com
>>
>> 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
>
>
>
> _________________________________________________________________________
> Professional FreeSWITCH Consulting Services:
> consulting at freeswitch.org
> http://www.freeswitchsolutions.com
>
> Official FreeSWITCH Sites
> http://www.freeswitch.org
> http://confluence.freeswitch.org
> http://www.cluecon.com
>
> 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/20150807/f7ba1de8/attachment.html 


Join us at ClueCon 2016 Aug 8-12, 2016
More information about the FreeSWITCH-users mailing list