[Freeswitch-users] recvEventTimed - SERVER_DISCONNECTED
Nagalenoj H.
nagalenoj at gmail.com
Thu Mar 4 21:07:10 PST 2010
Dear friends,
I've faced an issue in event socket. I would want to know why it
behaves such a way.
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.
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.
To handle this, I've checked esl connection inside the timeout part and
put a recvEvent, then I receive SERVER_DISCONNECTED.
My question is, why am I not receiving SERVER_DISCONNECTED when I recv
event using recvEventTimed?!
This is a sample program I execute,
require ESL;
use IO::Socket::INET;
my $ip = "127.0.0.1";
my $sock = new IO::Socket::INET ( LocalHost => $ip, LocalPort => '9242',
Proto => 'tcp', Listen => 1, Reuse => 1 );
die "Could not create socket: $!\n" unless $sock;
for(;;) {
my $new_sock = $sock->accept();
my $pid = fork();
if ($pid) {
close($new_sock);
next;
}
my $host = $new_sock->sockhost();
my $fd = fileno($new_sock);
my $con = new ESL::ESLconnection($fd);
my $info = $con->getInfo();
my $uuid = $info->getHeader("unique-id");
printf "Connected call %s, from %s\n", $uuid,
$info->getHeader("caller-caller-id-number");
my $e = $con->filter("unique-id", $uuid);
if ($e) {
print $e->serialize();
} else {
printf("WTF?\n");
}
$con->events("plain", "SERVER_DISCONNECTED DTMF");
$con->execute("answer");
while($con->connected()) {
$e = $con->recvEvent(); ############# CASE 1 ##
# $e = $con->recvEventTimed(10000); ############# CASE 2 ##
unless ($e) {
unless ($con->connected()) {
###############################
$e = $con->recvEvent(); ##
print $e->serialize(); ## Added
code to get SERVER_DISCONNECTED.
print "SERVER_DISCONNECTED"; ##
}
###############################
print "DTMF timeout\n";
}
if ($e) {
my $name = $e->getHeader("event-name");
print "EVENT [$name]\n";
if ($name eq "DTMF") {
my $digit = $e->getHeader("dtmf-digit");
my $duration = $e->getHeader("dtmf-duration");
print "DTMF digit $digit ($duration)\n";
}
}
}
print "BYE\n";
close($new_sock);
}
--
Regards,
Nagalenoj H.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20100305/c58798d3/attachment-0002.html
More information about the FreeSWITCH-users
mailing list