Hi all,<br><br>I've done a sample program (In perl ESL) , which play a file to the caller and then it will call recvEvent() and print the event name. I've handled signals also.<br><br>When I send SIGINT to my program (Perl), the signal handler is called and I can see the print output. But in the same time, I received SERVER_DISCONNECTED from freeswitch as event.<br>
<br>I don't know why I received SERVER_DISCONNECTED from freeswitch. Is it because, the recvEvent() from perl internally calls the recvevent function in the Esl.c and when it waits to receive the information from socket, the signal occurred???<br>
<br>Please clarify me!! <br><br>Here is my program<br>require ESL;<br>use IO::Socket::INET;<br>use Data::Dumper;<br><br>my $ip = "192.168.1.222";<br>my $sock = new IO::Socket::INET ( LocalHost => $ip, LocalPort => '8447', Proto => 'tcp', Listen => 1, Reuse => 1 );<br>
die "Could not create socket: $!\n" unless $sock;<br>&register_Signals();<br><br>for(;;) {<br> my $new_sock = $sock->accept();<br> next if (not defined ($new_sock));<br> my $pid = fork();<br> if ($pid) {<br>
close($new_sock);<br> next;<br> }<br> print "CHILD PID: $$\n";<br> my $host = $new_sock->sockhost();<br> my $fd = fileno($new_sock);<br><br> my $con = new ESL::ESLconnection($fd);<br>
my $info = $con->getInfo();<br><br> my $uuid = $info->getHeader("unique-id");<br><br> printf "Connected call %s, from %s\n", $uuid, $info->getHeader("caller-caller-id-number");<br>
my $r=$con->execute("answer");<br> print Dumper $r;<br> $con->events("plain","all");<br> my $re=$con->execute("playback","/usr/local/freeswitch1/sounds/en/us/callie/ivr/8000/ivr-welcome_to_freeswitch.wav");<br>
<br> while($con->connected()) {<br> my $e = $con->recvEvent();<br><br> if ($e) {<br> my $name = $e->getHeader("event-name");<br> print "EVENT [$name]\n";<br>
if ($name eq "DTMF") {<br> my $digit = $e->getHeader("dtmf-digit");<br> print "$digit\n";<br> }<br> }<br> }<br> close($new_sock);<br>
}<br>sub register_Signals() {<br> foreach ( keys %SIG ) {<br> $SIG{$_} = 'sig_Handler';<br> }<br>}<br><br>sub sig_Handler() {<br> my $handle=$_[0];<br> if($handle eq "INT") {<br> print "$$: SIGNAL SIG$handle is generated\n";<br>
}<br>}<br><br>