Anything wrong with this question?! I didn't find any replies for this..<br><br><div class="gmail_quote">On Fri, Mar 5, 2010 at 10:37 AM, Nagalenoj H. <span dir="ltr"><<a href="mailto:nagalenoj@gmail.com">nagalenoj@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Dear friends,<br> I've faced an issue in event socket. I would want to know why it behaves such a way.<br>
<br> My program is working with the hep of events. So, based on the received event, the process will continue it's work. When I need DTMF, I use recvEventTimed and in the other cases, I use recvEvent.<br>
So, In the mid if caller hangsup, I expect for the SERVER_DISCONNECTED event. When the caller hangsup when I'm waiting in recvEvent, I'm getting SERVER_DISCONNECTED. But, when I'm waiting in recvEventTimed, I'mnot receiving SERVER_DISCONNECTED, instead receiving an undefined value.<br>
<br> To handle this, I've checked esl connection inside the timeout part and put a recvEvent, then I receive SERVER_DISCONNECTED.<br><br> My question is, why am I not receiving SERVER_DISCONNECTED when I recv event using recvEventTimed?!<br>
<br>This is a sample program I execute,<br><br clear="all">require ESL;<br>use IO::Socket::INET;<br><br>my $ip = "127.0.0.1";<br>my $sock = new IO::Socket::INET ( LocalHost => $ip, LocalPort => '9242', Proto => 'tcp', Listen => 1, Reuse => 1 );<br>
die "Could not create socket: $!\n" unless $sock;<br><br>for(;;) {<br> my $new_sock = $sock->accept();<br> my $pid = fork();<br> if ($pid) {<br> close($new_sock);<br> next;<br> }<br><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> my $uuid = $info->getHeader("unique-id");<br> printf "Connected call %s, from %s\n", $uuid, $info->getHeader("caller-caller-id-number");<br>
<br> my $e = $con->filter("unique-id", $uuid);<br> if ($e) {<br> print $e->serialize();<br> } else {<br> printf("WTF?\n");<br> }<br> <br> $con->events("plain", "SERVER_DISCONNECTED DTMF");<br>
$con->execute("answer");<br> <br> while($con->connected()) {<br> $e = $con->recvEvent(); ############# CASE 1 ##<br> # $e = $con->recvEventTimed(10000); ############# CASE 2 ##<br>
<br> unless ($e) {<br> unless ($con->connected()) { ###############################<br> $e = $con->recvEvent(); ##<br> print $e->serialize(); ## Added code to get SERVER_DISCONNECTED.<br>
print "SERVER_DISCONNECTED"; ##<br> } ###############################<br> print "DTMF timeout\n";<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>
my $duration = $e->getHeader("dtmf-duration");<br> print "DTMF digit $digit ($duration)\n";<br> }<br> }<br> }<br> print "BYE\n";<br> close($new_sock);<br>}<br><br>
-- <br>Regards,<br><font color="#888888">Nagalenoj H.<br>
</font></blockquote></div><br><br clear="all"><br>-- <br>Regards,<br>Nagalenoj H.<br>