Question about Lua freeswitch.bridge
Hello! I'm a huge FreeSWITCH fan and am always amazed at how much I can do with it. I have a Lua script that has been working great, but now have been tasked with enhancing it, and have run into a problem. I want to be able to play media, detect DTMF and hang up a call after bridging two sessions, but my Lua script blocks on freeswitch.bridge(), and doesn't resume until one side or the other hangs up. Here is my problem reduced to a Lua script in its simplest form: -- first session session1 = session -- call out session2 = freeswitch.Session("{ignore_early_media=true}sofia/gateway/ etc.com/" .. phoneNumber) -- bridge the calls freeswitch.bridge(session1, session2) -- this next line doesn't execute until after either session 1 or 2 hangs up freeswitch.consoleLog("info", "This is a test.\n") How can I do an asynchronous bridge, and still be able to play media and detect dtmf afterwards? Mike van Lammeren
Just curious - would a bind_meta_app call work for you? I ask because you can't do asynchronous operations like you described when calling scripts from the dialplan. I'm afraid you will need to graduate to ESL. :) Check out ESL and the event socket on the wiki and chapter 9 of the FreeSWITCH book. Some things you will want to check out: uuid_broadcast (to play media to a channel) the DTMF event (http://wiki.freeswitch.org/wiki/Event_list#DTMF) fs-ivrd (example of a daemon that sits there and connects outbound event socket connects to an ESL script) Using the event socket allows total and complete 3rd party control of your sessions. The drawback is the the learning curve. It's a bit steep but it's worth it. -MC On Wed, Oct 6, 2010 at 9:18 AM, Mike van Lammeren <mike@van.lammeren.net>wrote:
Hello!
I'm a huge FreeSWITCH fan and am always amazed at how much I can do with it. I have a Lua script that has been working great, but now have been tasked with enhancing it, and have run into a problem.
I want to be able to play media, detect DTMF and hang up a call after bridging two sessions, but my Lua script blocks on freeswitch.bridge(), and doesn't resume until one side or the other hangs up.
Here is my problem reduced to a Lua script in its simplest form:
-- first session session1 = session -- call out session2 = freeswitch.Session("{ignore_early_media=true}sofia/gateway/ etc.com/" .. phoneNumber) -- bridge the calls freeswitch.bridge(session1, session2) -- this next line doesn't execute until after either session 1 or 2 hangs up freeswitch.consoleLog("info", "This is a test.\n")
How can I do an asynchronous bridge, and still be able to play media and detect dtmf afterwards?
Mike van Lammeren
_______________________________________________ FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
Hello! Thank you for your suggestions! I took a look at bind_meta_app in the wiki, and although it might be possible to do what I need, I think the best route will be to re-write my app to use mod_event_socket. There are some other feature requests that will be easier to support that way. I think I'm at the limit of what can be done with a Lua script. http://wiki.freeswitch.org/wiki/Misc._Dialplan_Tools_bind_meta_app http://wiki.freeswitch.org/wiki/Event_Socket I'll also be placing an order for the FreeSWITCH book! Thanks again! Mike van Lammeren On Wed, Oct 6, 2010 at 7:44 PM, Michael Collins <msc@freeswitch.org> wrote:
Just curious - would a bind_meta_app call work for you? I ask because you can't do asynchronous operations like you described when calling scripts from the dialplan. I'm afraid you will need to graduate to ESL. :) Check out ESL and the event socket on the wiki and chapter 9 of the FreeSWITCH book.
Some things you will want to check out: uuid_broadcast (to play media to a channel) the DTMF event (http://wiki.freeswitch.org/wiki/Event_list#DTMF) fs-ivrd (example of a daemon that sits there and connects outbound event socket connects to an ESL script)
Using the event socket allows total and complete 3rd party control of your sessions. The drawback is the the learning curve. It's a bit steep but it's worth it.
-MC
On Wed, Oct 6, 2010 at 9:18 AM, Mike van Lammeren <mike@van.lammeren.net>wrote:
Hello!
I'm a huge FreeSWITCH fan and am always amazed at how much I can do with it. I have a Lua script that has been working great, but now have been tasked with enhancing it, and have run into a problem.
I want to be able to play media, detect DTMF and hang up a call after bridging two sessions, but my Lua script blocks on freeswitch.bridge(), and doesn't resume until one side or the other hangs up.
Here is my problem reduced to a Lua script in its simplest form:
-- first session session1 = session -- call out session2 = freeswitch.Session("{ignore_early_media=true}sofia/gateway/ etc.com/" .. phoneNumber) -- bridge the calls freeswitch.bridge(session1, session2) -- this next line doesn't execute until after either session 1 or 2 hangs up freeswitch.consoleLog("info", "This is a test.\n")
How can I do an asynchronous bridge, and still be able to play media and detect dtmf afterwards?
Mike van Lammeren
_______________________________________________ FreeSWITCH-users mailing list FreeSWITCH-users@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@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
participants (2)
-
Michael Collins
-
Mike van Lammeren