[Freeswitch-users] nixevent behavior

lakshmanan ganapathy lakindia89 at gmail.com
Sat Jan 30 06:48:53 PST 2010


Dear all

I've done the following sample script to experiment the nixevent. I found
some difference in behavior because of nixevent. Let me explain my question
down the script.

require ESL;
use IO::Socket::INET;

my $ip = "192.168.1.222";
my $sock = new IO::Socket::INET ( LocalHost => $ip,  LocalPort => '8447',
Proto => 'tcp',  Listen => 1,  Reuse => 1 );
die "Could not create socket: $!\n" unless $sock;
for(;;) {
    my $new_sock = $sock->accept();
    next if (not defined ($new_sock));
    my $pid = fork();
    if ($pid) {
        close($new_sock);
        next;
    }
    print "CHILD PID: $$\n";
    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 $r=$con->execute("answer");
    $con->events("plain","all");
##########################
    $con->send("nixevent DTMF");
    my $val=$con->api("create_uuid");
    $val = $val->getBody();            # LINE 1
    chomp($val);
    print "UUID is $val\n";
    my $e = $con->recvEvent();
    $val = $e->getBody();               # LINE 2
    chomp($val);
    print "UUID is $val\n";
    close($new_sock);
}

# If the line ($con->send("nixevent DTMF");) is commented, then the result
of create_uuid is obtained in LINE 1.
# else, the result isn't obtained in the LINE 1 and it has nothing. The
result is obtained only when I do a recvEvent,
# followed by a getBody (LINE 2)

Just want to know why the behavior differs when nixevent is present???
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20100130/5912e565/attachment-0002.html 


More information about the FreeSWITCH-users mailing list