execute function in ESL.pm module is not working
Dear All, I registered alarm signal in my Perl server program. If ALARM signal occurred I execute the following statement in signal handler. "$conn->execute("playback",$sound_path."voicemail/vm-goodbye.wav")" The above statement didn't play that wave file. But before generating the ALARM signal it worked. What is the problem? Please help me in this problem.... Also Is there any idea to do timeout for DTMF digits? Thanks... Regards, K.Velusamy
Please any one help for this problem.. ---------- Forwarded message ---------- From: velusamy velu <velu.technical@gmail.com> Date: Wed, Aug 5, 2009 at 11:44 AM Subject: execute function in ESL.pm module is not working To: freeswitch-users@lists.freeswitch.org Dear All, I registered alarm signal in my Perl server program. If ALARM signal occurred I execute the following statement in signal handler. "$conn->execute("playback",$sound_path."voicemail/vm-goodbye.wav")" The above statement didn't play that wave file. But before generating the ALARM signal it worked. What is the problem? Please help me in this problem.... Also Is there any idea to do timeout for DTMF digits? Thanks... Regards, K.Velusamy
On Wed, Aug 5, 2009 at 11:38 PM, velusamy velu <velu.technical@gmail.com>wrote:
Please any one help for this problem..
Sorry for the delay but many of the FreeSWITCH experts are at ClueCon right now so we'll ask for your patience... in the meantime could you pastebin your script and your dialplan entry so that we can take a look at them? Thanks, MC
Dear Expert, Thanks for you reply.... My Perl Script is, use strict; use warnings; #--------------------------------------------------------------------------- # Event socket library. # Socket programming # printing the data structures # Using posix parametered functions. #--------------------------------------------------------------------------- use lib('/root/freeswitch-1.0.3/libs/esl/perl/'); require ESL; use IO::Socket::INET; use Data::Dumper qw(Dumper); use POSIX; use Config::IniFiles; # Global variables to store the socket connection and eneterd DTM digits. my ($conn,$digit); $digit=''; #Registering the ALARM signal. $SIG{ALRM}=\&sub_alr; # When alarm signal occurs call the play_digit function sub sub_alr { print "IN Sigalarm---\n"; &play_digit; return ; } # ---------- end of subroutine sub_alr ---------- # Play the voice files for menu. sub play(){ $conn->execute("playback","ivr/ivr-please.wav"); $conn->execute("playback","ivr/ivr-enter_ext.wav"); } sub play_digit { print "In Play Digit....\n"; my ( $par1 ) = $digit; #$digit is global variable print "Eneterd Digits=",$digit,"\n"; ################################################################ # Here what is my problem the execute function is not working # ################################################################ $conn->execute("phrase", "spell,$par1"); return ; } # ---------- end of subroutine play_digit ---------- #--------------------------------------------------------------------------- # IP address and port of the server. # Sound path file. #--------------------------------------------------------------------------- my $ip = "192.168.1.222"; my $port = '5057'; my $sound_path = "/usr/local/freeswitch/sounds/en/us/callie/"; # Creating a socket my $sock = new IO::Socket::INET ( LocalHost => $ip, LocalPort => $port, Proto => 'tcp', Listen => 1, Reuse => 1 ); # Checking the error. die "Cannot create a socket:$!\n" unless $sock; for(;;){ my $new_socket = $sock->accept(); print "Current Process Id:".POSIX::getpid()."\n"; my $pid = fork(); if($pid){ close($new_socket); next; } print "Child Process Id:".POSIX::getpid()."\n"; my $fd = fileno($new_socket); print "File Number:$fd\n"; # Create a conenction with Event socket library. $conn = new ESL::ESLconnection($fd); # Getting the connection informations and values of the variables. my $info = $conn->getInfo(); # Getting the caller id and print the statement. my $caller_id =$info->getHeader("caller-caller-id-number"); printf "Connected from %s\n", $caller_id; # Receive the events from only in this switch. $conn->sendRecv("myevents"); # Answer the call. $conn->execute("answer"); # playback the welcome message. $conn->setEventLock("true"); $conn->execute("playback",$sound_path."ivr/ivr-welcome_to_freeswitch.wav"); $conn->execute("sleep", "1000"); &play; alarm(10); while($conn->connected()){ # Receive the event my $event = $conn->recvEvent(); # Check the event is received if($event){ # Get the event name and print it. my $name = $event->getHeader("event-name"); print "EVENT:[$name]\n"; # If the event name is DTMF then print the enterted digit. if($name eq 'DTMF'){ my $digi = $event->getHeader("dtmf-digit"); # Here concatenate the eneterd digits $digit.=$digi; } } } # Kill the child process. print "Disconnected:$caller_id\n"; kill 9,POSIX::getpid(); } My dial plan is, <!-- Testing IVR --> <extension name="Test"> <condition field="destination_number" expression="^(200)$"> <action application="socket" data="192.168.1.222:5057 async full"/> </condition> </extension> The output of the Script is, Current Process Id:2906 Child Process Id:2908 File Number:4 Connected from 1000 EVENT:[CHANNEL_EXECUTE] EVENT:[CHANNEL_ANSWER] EVENT:[CHANNEL_EXECUTE_COMPLETE] EVENT:[CHANNEL_EXECUTE] EVENT:[CHANNEL_EXECUTE_COMPLETE] EVENT:[CHANNEL_EXECUTE] EVENT:[CHANNEL_EXECUTE_COMPLETE] EVENT:[CHANNEL_EXECUTE] EVENT:[CHANNEL_EXECUTE_COMPLETE] EVENT:[CHANNEL_EXECUTE] EVENT:[CHANNEL_EXECUTE_COMPLETE] EVENT:[DTMF] EVENT:[DTMF] EVENT:[DTMF] EVENT:[DTMF] IN Sigalarm--- In Play Digit.... Eneterd Digits=7485 Disconnected:1000 When alarm signal generated, it prints digits but it won't execute the "execute" function.. Please any one give suggestions where I made wrong... Thanks... Regards, Velusamy. On Thu, Aug 6, 2009 at 11:24 AM, Michael Collins <msc@freeswitch.org> wrote:
On Wed, Aug 5, 2009 at 11:38 PM, velusamy velu <velu.technical@gmail.com>wrote:
Please any one help for this problem..
Sorry for the delay but many of the FreeSWITCH experts are at ClueCon right now so we'll ask for your patience... in the meantime could you pastebin your script and your dialplan entry so that we can take a look at them?
Thanks, MC
_______________________________________________ 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
-
velusamy velu