[Freeswitch-users] Running a session asynchronously from a Lua script

Brian West brian at freeswitch.org
Thu Feb 4 19:23:46 PST 2010


I wouldn't do it like that...

I would let FreeSWITCH do what its good at and stop trying to create and manage sessions manually.

-- You can optionally answer but you need to set transfer_ringback instead of ringback.
session:setVariable("ringback", "local_stream://moh");                                                                                                          
session:setVariable("ignore_early_media", "true");                                                                                                              
session:execute("bridge","user/1007");  

Which can also be expressed in pure XML as such:

<extension name="1234">
  <condition field="destination_number" expression="^1234$">                                                                                                
    <action application="set" data="ringback=local_stream://moh"/>
    <action application="set" data="ignore_early_media=true"/>
    <action application="bridge" data="user/1007"/>
  </condition>
</extension>

There is really no need to do this with Lua.  The XML dialplan can do some VERY complex things once you wrap your head around it.

In addition I would recommend you get the latest 1.0.5 build http://files-sync.freeswitch.org/windows_installer/  Its tagged as 1.0.4 and shouldn't be.

/b



On Feb 4, 2010, at 8:48 PM, Adam Wilt wrote:

> Hi all,
> 
> I want to park an inbound call and play hold music while I simultaneously place another outbound call.
> But the hold music doesn't play while the lua script is placing the second call. When the lua script ends, the hold music finally starts. 
> Here's my example code:
> 
> #!/usr/local/bin/lua
>    
> session:answer()
> api = freeswitch.API()
> api:executeString("bgapi uuid_park " .. tostring(session.uuid))
> api:executeString("bgapi uuid_broadcast " .. tostring(session.uuid)  .. " /freeswitch/sounds/music/8000/danza-espanola-op-37-h-142-xii-arabesca.wav")
> local new_session = freeswitch.Session("sofia/gateway/myprovider/15555555555")
> 
> So it seems like the script is blocking the original session, despite the fact that I'm using bgapi.  I'd really appreciate if somebody could help me with this.
> 
> By the way, I'm using FreeSWITCH 1.0.4 in Windows.
> 
> Thanks,
> Adam

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20100204/c4c1fc03/attachment-0002.html 


More information about the FreeSWITCH-users mailing list