[Freeswitch-users] Lua outbound executing another lua script

Alpha Niner alphaniner at me.com
Thu Jul 19 17:18:10 MSD 2012


Hi,

Firstly apologies for the newbie question.  I've tried searching the various documentation and trying a few different things but to no avail, so I've come here to ask for help.  I think my problem relates to sessions, but I'm not totally sure.

What I'm trying to do is:

1.  A lua script is run by someone calling into FS (the initiator)
2.  They select an option, which originates and makes an outbound call to another phone number
3.  The 3rd party (hopefully) answers their phone and receives a prompt that they're going to be connected (the receiver)
4.  Both parties join a conference and talk to each other (a conference as there may be other parties in future)

To do this I'm creating a session and using execute_on_answer to run the second script and provide the prompt to the receiving party.  However the receiving party never hears a prompt, comes into the conference, immediately drops out and hangs up.

Here are the scripts, they're pretty simple;

The initiator:

session:answer()
session:streamFile("WaitForOutdial.wav")
new_session = freeswitch.Session("[execute_on_answer=lua /usr/local/freeswitch/scripts/receivewithwhisper.lua]sofia/external/12345 at mydest");
session:execute("conference", "CONFTEST at default+flags{endconf, moderator}")
session:hangup();

The above works fine and the outbound call is placed.  The script below is then executed but the receiving phone rings but nothing is heard, the conference is joined/exited and it terminates again;


The receiver (receivewithwhisper.lua):

session:answer()
session:streamFile("ConnectingToCaller.wav")
session:execute("conference", "CONFTEST at default+flags{endconf, moderator}")
session:hangup();

The receiving scripts runs when the receiver answers their phone, and executes (quickly) and terminates.  I was expecting it to drop into the conference and I'd be able to talk to the other person.  It does join the conference, but then exits right away and falls through to the hangup section.

As I say, I'm not exactly sure if this is the best way (maybe there's another - suggestions are welcome) and not exactly sure what the problem is although I suspect it's something to do with the sessions?

Any help, advice, corrections or examples would be appreciated.  It's all done in lua and I've tried to avoid session.originate as I understand this is deprecated.

Thanks

Adam


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20120719/51a90377/attachment.html 


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