Alex,<br><br>I noticed that you are using the same thing as Michael Lutz from the other thread we just discussed. Could you try recvEventTimed(1) instead of recvEventTimed(0)? I'm curious to see if it changes the behavior of your application at all.<br>
<br>-MC<br><br><div class="gmail_quote">On Fri, Apr 6, 2012 at 12:21 PM, Alex Crow <span dir="ltr"><<a href="mailto:acrow@integrafin.co.uk">acrow@integrafin.co.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On 06/04/12 19:19, Anthony Minessale wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I think you might be twisted around its possible that doing what you<br>
are doing is much more complicated than just using the socket app.<br>
If you are just trying to play a file and get a digits etc you could<br>
do it all with existing dialplan apps.<br>
</blockquote>
<br>
Anthony,<br>
<br>
Thanks very much for replying: what I wanted it it to do is things like ask a user if he'd like to set a pin for hotdesking (stored in a database, initially sqlite and later mysql or postgres), to check that pin when doing a login that logs out his existing extensions (if they exist), and various other features later such as creating their own conferences with a pin of their choosing.<br>
<br>
I thought the easiest way for the first task (and possibly others) would just be to set an extension in the dialplan to call a PHP page on a webserver via a curl action, passing some session variables, which would then take over the control of the call. I've already have written all the stuff for logging in/out and automatically rebooting/provisioning both Polycom and Snom phones but have been asked to add some security so someone can't just move someone else's registration to another device.<br>
<br>
If you think that approach is wrong/doomed to failure and explain what the socket app is (is that the thing where you attach a call from the dialplan to a TCP socket? Then I've have to learn about setting up a listening app in PHP (or any other language), rather than via the webserver, wouldn't I, and then try and figure our how to filter our all the events from all the other calls, know which event I want, act on it, etc)<br>
<br>
I just think that what I'm doing should be theoretically possible (if not the most elegant way) and just can't figure out why if I leave out the whole polling for events bit then the message is played, but as soon as I try to capture events *after* I've sent the execute call I never hear the message.<br>
<br>
Just completely confused and am loathe to have to rewrite my hotdesking stuff which so far is really simple, I've attached the whole PHP app code here so you can see what I've done (it's only the "action=test" calling "saySomething" that I have been asking about.<br>
<br>
Ideally I'd like to become at least adept if not expert in FS within a year as that would be the time we would think about replacing our existing phone system.<br>
<br>
Cheers<br>
<br>
Alex<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
<br>
<br>
On Fri, Apr 6, 2012 at 12:31 PM, Alex Crow<<a href="mailto:acrow@integrafin.co.uk" target="_blank">acrow@integrafin.co.uk</a>> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On 01/04/12 17:29, Alex Crow wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On 01/04/12 11:26, Peter Olsson wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
In your sample you're actually queuing "sleep(1000)" to the channel.<br>
So first it will queue play_and_get_digits, inside that loop it will<br>
find more commands in the queue, and exeute them, so in the end it<br>
will only execute a bunch of "sleep(1000)".<br>
<br>
You're better of using a sleep in your module directly (not tell FS<br>
to sleep). Also you will need to poll the events in the loop<br>
somehow., checkout the perl sample here:<br>
<a href="http://wiki.freeswitch.org/wiki/Esl#Simple_Perl_Example" target="_blank">http://wiki.freeswitch.org/<u></u>wiki/Esl#Simple_Perl_Example</a><br>
</blockquote>
Peter,<br>
<br>
I've changed to the below (adapted that Perl example) and I only hear<br>
the prompt for digits when the webserver times out after 60 seconds.<br>
Any time I make any call to ESL after the execute, I don't hear the<br>
prompt in a timely fashion. This is so complicated as I'm not really<br>
that good at software development, I'm more a systems/networks guy. I<br>
feel like a total thickie here, but the docs don't seem to explain in<br>
which order I should call things and expect to get replies, etc.<br>
<br>
$esl = new ESLconnection('localhost','<u></u>8021','ClueCon');<br>
<br>
$event = $esl->events('plain', 'ALL');<br>
//$event = $esl->filter("Unique-ID",$<u></u>uuid);<br>
<br>
sleep (1);<br>
<br>
$res = $esl->execute("play_and_get_<u></u>digits","4 11 1 5000 #<br>
ivr/ivr-please_enter_the_<u></u>phone_number.wav<br>
ivr/ivr-that_was_an_invalid_<u></u>entry.wav target_num \d+", "$uuid");<br>
<br>
$job_uuid = $res->getHeader("Job-UUID");<br>
$status = $res->getHeader("Reply-Text");<br>
<br>
<br>
<br>
//$foo = $uuid . ' target_num';<br>
<br>
echo $status;<br>
<br>
$stay_connected = 1;<br>
while ( $stay_connected ) {<br>
$e = $esl->recvEventTimed(0);<br>
if ( $e ) {<br>
$ev_name = $e->getHeader("Event-Name");<br>
# Should we check for the $job_uuid to match the background job ?<br>
//if ( $ev_name == 'BACKGROUND_JOB' ) {<br>
// if ( $e->getHeader("Job-UUID") == $uuid ) {<br>
// $call_result = $e->getBody();<br>
// echo "Result of call to $target was $call_result\n\n";<br>
// }<br>
//} else<br>
echo $ev_name;<br>
if ( $ev_name == 'EXECUTE_COMPLETE' ) {<br>
//my $digit = $e->getHeader("DTMF-Digit");<br>
// print "Received DTMF digit: $digit\n";<br>
//if ( $digit =~ m/\D/ ) {a<br>
// print "Exiting...\n";<br>
//if ( $e->getHeader("Job-UUID") == $job_uuid ) {<br>
$stay_connected = 0;<br>
//}<br>
//}<br>
} else {<br>
# Some other event<br>
}<br>
} else {<br>
# do other things while waiting for events<br>
//sleep (1);<br>
}<br>
}<br>
<br>
$event=$esl->sendRecv("api uuid_getvar $uuid target_num");<br>
<br>
<br>
$ret = $event->getBody();<br>
<br>
$esl->disconnect();<br>
<br>
Apologies for my newbishness and many thanks for your help so far.<br>
<br>
Hoping for an epiphany when I sudddenly understand what I am doing!<br>
<br>
Alex<br>
</blockquote>
Can anyone help with this? I updated to latest Git, thinking it may have<br>
been a bug, and still have the same problem, when I try to wait for<br>
events as in the above code, it stops the playback of the "enter the<br>
phone number" from happening until after the web server times out.<br>
<br>
Logically I can't see a reason for this, is it because you can't use an<br>
inbound connection activated by calling from curl in the dialplan? If<br>
this is indeed the case I could try rewriting this for outbound but I<br>
feel that will be more complex for a relative beginner programmer.<br>
<br>
If I have missed some vital or obvious concept feel free to chastise me :-).<br>
<br>
Thanks<br>
<br>
Alex<br><br></blockquote></blockquote></blockquote></div>