[Freeswitch-users] Execute app in sync mode when using event sockets
Peter Olsson
POlsson at enghouse.com
Fri Feb 1 18:12:56 MSK 2013
My best suggestion is to "think different". If you're using ESL in inbound mode, you probably don't want to block the socket for anything, since you might receive events for other channels etc.
The best way is to use it asynchronous - as intended. Send the speak command, and then trigger on the event that is sent when the playback is finished.
In my use case I use it for an IVR system, I have the ESL lib, and then I create one thread per new channel (could be done differently, but it was the easiest approach right now). Then I queue the events for the separate channels back into their threads (separated per channel uuid). In the thread I do the things I want asynchronously, then I wait for events to be queued to my thread, and I handle these events. When I get the reply that the playback is finished, I do the next step etc.
/Peter
Från: freeswitch-users-bounces at lists.freeswitch.org [mailto:freeswitch-users-bounces at lists.freeswitch.org] För Hector Geraldino
Skickat: den 31 januari 2013 20:19
Till: FreeSWITCH Users Help
Ämne: [Freeswitch-users] Execute app in sync mode when using event sockets
Hi,
I have a java app that uses mod_event_socket (inbound mode) to control FreeSWITCH. I can send api commands which, by default, are synchronous, so the thread locks until the command is successfully executed. The problem I'm facing is when I have to execute commands that are in other modules (like playback, or speak). As they are not api commands, I must send an execute appName + arguments, which by nature is executed in async mode.
What I want to achieve is to execute an speak command and wait until the TTS operation ends (blocking the thread). This sounds like a trivial use case: play some audio (TTS, file) and then execute the rest of the logic. It is easy to accomplish on the dialplan, but I just can't figure out how to do it on an ESL application. Here's what I've tried so far:
+ send execute speak command + api sleep and wait for the CHANNEL_EXECUTE_COMPLETE (to simulate a lock [sleep] and continue [break after event is received]), but the event arrives after the sleep command completes.
+ use uuid_broadcast uuid speak::args, doesn't work
Any hints, ideas are welcomed.
Thank you!
Hector
!DSPAM:510ac0b632761097822086!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20130201/5aee7382/attachment.html
Join us at ClueCon 2011 Aug 9-11, 2011
More information about the FreeSWITCH-users
mailing list