[Freeswitch-users] Executing Multiple Applications in parallel

JP jaykris at gmail.com
Sun Jan 27 05:45:44 MSK 2013


Thanks Anthony!! That works perfectly. This is what I did...

    <extension name="MY TEST">
      <condition field="destination_number" expression="8027">
            <action application="answer"/>
            <action application="play_and_get_digits" data="4 16 3 7000 #
phrase:Callidus_OD_Prompt phrase:Callidus_invalid_entry case_number \d+" />
            <action application="set" data="x=${expand(luarun
callidus_get_customer_info.lua ${case_number} ${uuid})}"/>
            <action application = "playback"
data="/tmp/WPJ_MUSIC_QUEUE_4.wav"/>
       </condition>
    </extension>

This is pretty neat. It should be on the wiki. If someone can suggest the
best place to place this on the wiki, I can update it.

Thank you,
JP

On Fri, Jan 25, 2013 at 8:37 PM, Anthony Minessale <
anthony.minessale at gmail.com> wrote:

> only non-ESL method to do what you want....
>
> 1) make the dialplan use the FSAPI via variable expansion to call luarun
> on the script with the uuid as the first arg (this will go in a new thread)
> 2) play your long file
> 3) do what you need to do and then use the uuid to feed to uuid_transfer
> api
>
>
>
>
> On Fri, Jan 25, 2013 at 10:26 PM, Usama Zaidi <itsusama at gmail.com> wrote:
>
>> http://pastebin.freeswitch.org/20508 I just checked the link and it
>> works...
>>
>>
>> On Sat, Jan 26, 2013 at 5:44 AM, Usama Zaidi <itsusama at gmail.com> wrote:
>>
>>> Hey,
>>>
>>> I posted this earlier as a question, but I think this might be relevant.
>>> ttp://pastebin.freeswitch.org/20508<http://pastebin.freeswitch.org/20508>.
>>> The workaround (hack) for my issue is to check the connection state
>>> ($con->connected()) every time you loop and reconnect and subscribe for
>>> events again when that returns false.
>>>
>>> On Sat, Jan 26, 2013 at 5:33 AM, <
>>> freeswitch-users-request at lists.freeswitch.org> wrote:
>>>
>>>> Send FreeSWITCH-users mailing list submissions to
>>>>         freeswitch-users at lists.freeswitch.org
>>>>
>>>> To subscribe or unsubscribe via the World Wide Web, visit
>>>>         http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
>>>> or, via email, send a message with subject or body 'help' to
>>>>         freeswitch-users-request at lists.freeswitch.org
>>>>
>>>> You can reach the person managing the list at
>>>>         freeswitch-users-owner at lists.freeswitch.org
>>>>
>>>> When replying, please edit your Subject line so it is more specific
>>>> than "Re: Contents of FreeSWITCH-users digest..."
>>>>
>>>> Today's Topics:
>>>>
>>>>    1. Re: Executing multiple applications in parallel (Michael Collins)
>>>>    2. Re: Executing multiple applications in parallel (JP)
>>>>
>>>>
>>>> ---------- Forwarded message ----------
>>>> From: Michael Collins <msc at freeswitch.org>
>>>> To: FreeSWITCH Users Help <freeswitch-users at lists.freeswitch.org>
>>>> Cc:
>>>> Date: Fri, 25 Jan 2013 16:10:37 -0800
>>>> Subject: Re: [Freeswitch-users] Executing multiple applications in
>>>> parallel
>>>> The problem you're running into is that you are trying to do two
>>>> different things inside of the thread that is controlling the call flow.
>>>> Playing sound files and running Lua scripts are synchronous in this
>>>> context. This seems more suited for an outbound event socket application.
>>>> Using the event socket you can control the call while doing other things.
>>>>
>>>> Just curious - does anyone have an ESL example of this kind of thing?
>>>> The wiki could definitely use this kind of example as it is quite useful.
>>>> I'll look around and see if I can find anything.
>>>>
>>>> -MC
>>>>
>>>> On Fri, Jan 25, 2013 at 3:00 PM, JP <jaykris at gmail.com> wrote:
>>>>
>>>>> Avi,
>>>>> Thanks for the response. Unfortunately that did not work. This is what
>>>>> I did
>>>>>
>>>>>
>>>>>     <extension name="MyExtension">
>>>>>       <condition field="destination_number" expression="9005">
>>>>>             <action application="answer"/>
>>>>>             <action application="play_and_get_digits" data="4 16 3
>>>>> 7000 # phrase:MyPrompt phrase:My_invalid_entry case_number \d+" />
>>>>>             <action application="playback" data="phrase:wait_msg" />
>>>>>             <action application="sched_broadcast" data="+0
>>>>> playback::/tmp/WPJ_MUSIC_QUEUE_4.wav"/>
>>>>>             <action application="lua" data="get_customer_info.lua
>>>>> ${case_number}" />
>>>>>        </condition>
>>>>>     </extension>
>>>>>
>>>>> The music only plays after the Lua script exits. I played around with
>>>>> the timer value, but that did not help either. Any other ideas?
>>>>>
>>>>> Thanks
>>>>> JP
>>>>>
>>>>>
>>>>> On Fri, Jan 25, 2013 at 1:22 AM, Avi Marcus <avi at avimarcus.net> wrote:
>>>>>
>>>>>> ESL gives you more control, especially to execute things in parallel.
>>>>>> If you want to do it within FS, that's a little more complicated,
>>>>>> since most things are sequential.
>>>>>>
>>>>>> However, if you use the async APIs, then I think it could work:
>>>>>> 1) sched_broadcast<http://wiki.freeswitch.org/wiki/Misc._Dialplan_Tools_sched_broadcast> --
>>>>>> schedule the playback of your file on the UUID of the channel, for +0,
>>>>>> meaning now.
>>>>>> 2) run your lua script
>>>>>> 3) Then stop (break) the playback on that uuid: break<http://wiki.freeswitch.org/wiki/Misc._Dialplan_Tools_break>
>>>>>> 4) Continue with your execution.
>>>>>>
>>>>>> Please wikify your results and let us know how that works out!
>>>>>> -Avi
>>>>>>
>>>>>>  On Fri, Jan 25, 2013 at 3:34 AM, JP <jaykris at gmail.com> wrote:
>>>>>>
>>>>>>>  I want to do the following...
>>>>>>>
>>>>>>> 1. Play a long music file from a dialplan.
>>>>>>> 2. While the music is playing, I want to launch a Lua script to do
>>>>>>> some data dip.
>>>>>>> 3. Once the data is fetched and Lua exits, I want to interrupt the
>>>>>>> music and continue in the dialplan
>>>>>>>
>>>>>>> How do I do this. Any sample code or pointers would be greatly
>>>>>>> appreciated.
>>>>>>>
>>>>>>> Thanks
>>>>>>>
>>>>>>>
>>>>>>> _________________________________________________________________________
>>>>>>> Professional FreeSWITCH Consulting Services:
>>>>>>> consulting at freeswitch.org
>>>>>>> http://www.freeswitchsolutions.com
>>>>>>>
>>>>>>> 
>>>>>>> 
>>>>>>>
>>>>>>> Official FreeSWITCH Sites
>>>>>>> http://www.freeswitch.org
>>>>>>> http://wiki.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://wiki.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://wiki.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
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> Michael S Collins
>>>> Twitter: @mercutioviz
>>>> http://www.FreeSWITCH.org
>>>> http://www.ClueCon.com
>>>> http://www.OSTAG.org
>>>>
>>>>
>>>>
>>>> ---------- Forwarded message ----------
>>>> From: JP <jaykris at gmail.com>
>>>> To: FreeSWITCH Users Help <freeswitch-users at lists.freeswitch.org>
>>>> Cc:
>>>> Date: Fri, 25 Jan 2013 16:32:50 -0800
>>>> Subject: Re: [Freeswitch-users] Executing multiple applications in
>>>> parallel
>>>> MC,
>>>> Thanks for the info. Unfortunately outbound event socket application is
>>>> not an option for me right now. I was wondering if the following "ideas"
>>>> can be of any use to me( I know I am trying clutch at straws, but hope is
>>>> eternal :))
>>>> 1. Use "bgapi". Although on the wiki I only see this used with
>>>> "originate".
>>>> 2. Can I use a conference to park the caller there while playing music
>>>> on another call leg of the conference. Meanwhile can I execute the Lua
>>>> script :))
>>>> 3. Can I launch another Lua script from my original one asynchronously?
>>>> 4. Can I have a start up Lua script running in the background listening
>>>> for some custom events and I can have the main caller thread generate the
>>>> custom event and then start playing long music file. Once the background
>>>> Lua script is done with the data dip, it can just break the music on the
>>>> other channel.
>>>>
>>>> That's it from me. Someone help me from sinking... please.
>>>>
>>>> Thanks,
>>>> -JP
>>>>
>>>>
>>>> On Fri, Jan 25, 2013 at 4:10 PM, Michael Collins <msc at freeswitch.org>wrote:
>>>>
>>>>> The problem you're running into is that you are trying to do two
>>>>> different things inside of the thread that is controlling the call flow.
>>>>> Playing sound files and running Lua scripts are synchronous in this
>>>>> context. This seems more suited for an outbound event socket application.
>>>>> Using the event socket you can control the call while doing other things.
>>>>>
>>>>> Just curious - does anyone have an ESL example of this kind of thing?
>>>>> The wiki could definitely use this kind of example as it is quite useful.
>>>>> I'll look around and see if I can find anything.
>>>>>
>>>>> -MC
>>>>>
>>>>>
>>>>> On Fri, Jan 25, 2013 at 3:00 PM, JP <jaykris at gmail.com> wrote:
>>>>>
>>>>>> Avi,
>>>>>> Thanks for the response. Unfortunately that did not work. This is
>>>>>> what I did
>>>>>>
>>>>>>
>>>>>>     <extension name="MyExtension">
>>>>>>       <condition field="destination_number" expression="9005">
>>>>>>             <action application="answer"/>
>>>>>>             <action application="play_and_get_digits" data="4 16 3
>>>>>> 7000 # phrase:MyPrompt phrase:My_invalid_entry case_number \d+" />
>>>>>>             <action application="playback" data="phrase:wait_msg" />
>>>>>>             <action application="sched_broadcast" data="+0
>>>>>> playback::/tmp/WPJ_MUSIC_QUEUE_4.wav"/>
>>>>>>             <action application="lua" data="get_customer_info.lua
>>>>>> ${case_number}" />
>>>>>>        </condition>
>>>>>>     </extension>
>>>>>>
>>>>>> The music only plays after the Lua script exits. I played around with
>>>>>> the timer value, but that did not help either. Any other ideas?
>>>>>>
>>>>>> Thanks
>>>>>> JP
>>>>>>
>>>>>>
>>>>>> On Fri, Jan 25, 2013 at 1:22 AM, Avi Marcus <avi at avimarcus.net>wrote:
>>>>>>
>>>>>>> ESL gives you more control, especially to execute things in parallel.
>>>>>>> If you want to do it within FS, that's a little more complicated,
>>>>>>> since most things are sequential.
>>>>>>>
>>>>>>> However, if you use the async APIs, then I think it could work:
>>>>>>> 1) sched_broadcast<http://wiki.freeswitch.org/wiki/Misc._Dialplan_Tools_sched_broadcast> --
>>>>>>> schedule the playback of your file on the UUID of the channel, for +0,
>>>>>>> meaning now.
>>>>>>> 2) run your lua script
>>>>>>> 3) Then stop (break) the playback on that uuid: break<http://wiki.freeswitch.org/wiki/Misc._Dialplan_Tools_break>
>>>>>>> 4) Continue with your execution.
>>>>>>>
>>>>>>> Please wikify your results and let us know how that works out!
>>>>>>> -Avi
>>>>>>>
>>>>>>>  On Fri, Jan 25, 2013 at 3:34 AM, JP <jaykris at gmail.com> wrote:
>>>>>>>
>>>>>>>>  I want to do the following...
>>>>>>>>
>>>>>>>> 1. Play a long music file from a dialplan.
>>>>>>>> 2. While the music is playing, I want to launch a Lua script to do
>>>>>>>> some data dip.
>>>>>>>> 3. Once the data is fetched and Lua exits, I want to interrupt the
>>>>>>>> music and continue in the dialplan
>>>>>>>>
>>>>>>>> How do I do this. Any sample code or pointers would be greatly
>>>>>>>> appreciated.
>>>>>>>>
>>>>>>>> Thanks
>>>>>>>>
>>>>>>>>
>>>>>>>> _________________________________________________________________________
>>>>>>>> Professional FreeSWITCH Consulting Services:
>>>>>>>> consulting at freeswitch.org
>>>>>>>> http://www.freeswitchsolutions.com
>>>>>>>>
>>>>>>>> 
>>>>>>>> 
>>>>>>>>
>>>>>>>> Official FreeSWITCH Sites
>>>>>>>> http://www.freeswitch.org
>>>>>>>> http://wiki.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://wiki.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://wiki.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
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Michael S Collins
>>>>> Twitter: @mercutioviz
>>>>> http://www.FreeSWITCH.org
>>>>> http://www.ClueCon.com
>>>>> http://www.OSTAG.org
>>>>>
>>>>>
>>>>>
>>>>> _________________________________________________________________________
>>>>> Professional FreeSWITCH Consulting Services:
>>>>> consulting at freeswitch.org
>>>>> http://www.freeswitchsolutions.com
>>>>>
>>>>> 
>>>>> 
>>>>>
>>>>> Official FreeSWITCH Sites
>>>>> http://www.freeswitch.org
>>>>> http://wiki.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
>>>>>
>>>>>
>>>>
>>>> _______________________________________________
>>>> 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
>>>>
>>>>
>>>
>>>
>>> --
>>> I'd love to change the world, but they wont gimme the source code to it
>>>
>>
>>
>>
>> --
>> I'd love to change the world, but they wont gimme the source code to it
>>
>> _________________________________________________________________________
>> Professional FreeSWITCH Consulting Services:
>> consulting at freeswitch.org
>> http://www.freeswitchsolutions.com
>>
>> 
>> 
>>
>> Official FreeSWITCH Sites
>> http://www.freeswitch.org
>> http://wiki.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
>>
>>
>
>
> --
> Anthony Minessale II
>
> FreeSWITCH http://www.freeswitch.org/
> ClueCon http://www.cluecon.com/
> Twitter: http://twitter.com/FreeSWITCH_wire
>
> AIM: anthm
> MSN:anthony_minessale at hotmail.com
> GTALK/JABBER/PAYPAL:anthony.minessale at gmail.com
> IRC: irc.freenode.net #freeswitch
>
> FreeSWITCH Developer Conference
> sip:888 at conference.freeswitch.org
> googletalk:conf+888 at conference.freeswitch.org
> pstn:+19193869900
>
> _________________________________________________________________________
> Professional FreeSWITCH Consulting Services:
> consulting at freeswitch.org
> http://www.freeswitchsolutions.com
>
> 
> 
>
> Official FreeSWITCH Sites
> http://www.freeswitch.org
> http://wiki.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/20130126/a5267282/attachment-0001.html 


Join us at ClueCon 2011 Aug 9-11, 2011
More information about the FreeSWITCH-users mailing list