2007-01-06 12:06:18 -05:00
|
|
|
#!/usr/bin/perl
|
|
|
|
use FreeSWITCH::Client;
|
|
|
|
use Data::Dumper;
|
|
|
|
|
|
|
|
my $fs = init FreeSWITCH::Client {} or die "Error $@";
|
|
|
|
my $pid;
|
|
|
|
|
|
|
|
for (;;) {
|
|
|
|
$fs->accept();
|
|
|
|
|
|
|
|
if (!($pid = fork)) {
|
|
|
|
last;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
my $data = $fs->call_data();
|
|
|
|
|
|
|
|
#print Dumper $data
|
|
|
|
print "Call: $data->{'caller-channel-name'} $data->{'unique-id'}\n";
|
|
|
|
|
|
|
|
|
|
|
|
$o = $fs->call_command("answer");
|
|
|
|
#to turn on events when in async mode
|
2007-06-22 23:26:12 -04:00
|
|
|
$o = $fs->raw_command("myevents");
|
2008-01-07 13:21:34 -05:00
|
|
|
$o = $fs->call_command("playback", "/ram/swimp.raw");
|
2007-06-25 17:25:33 -04:00
|
|
|
|
2007-01-06 12:06:18 -05:00
|
|
|
|
|
|
|
#comment exit in async mode
|
2007-06-22 23:26:12 -04:00
|
|
|
#exit;
|
2007-01-06 12:06:18 -05:00
|
|
|
|
|
|
|
while(my $r = $fs->readhash(undef)) {
|
|
|
|
if ($r->{socketerror}) {
|
|
|
|
last;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($r->{has_event}) {
|
|
|
|
print Dumper $r->{event};
|
|
|
|
}
|
2007-06-25 17:25:33 -04:00
|
|
|
if ($r->{event}->{'event-name'} !~ /execute/i) {
|
2008-01-07 13:21:34 -05:00
|
|
|
printf "uuid: $data->{'unique-id'}\n";
|
2007-06-25 17:25:33 -04:00
|
|
|
$o = $fs->call_command("break");
|
|
|
|
$o = $fs->call_command("hangup");
|
|
|
|
}
|
2007-01-06 12:06:18 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
$fs->disconnect();
|
|
|
|
print "done\n";
|
|
|
|
|
|
|
|
|