ESL: Examples in Perl
Lets see how to use the Perl ESL implementation to connect and interact with the Event System in a FreeSWITCH server.
Display Filtered Events
A command line utility that connects to FreeSWITCH listening socket, subscribe to all events (don't do this on a busy server), and then display only selected types, further filtered on values in chosen headers.
#!/usr/bin/perl
require ESL;
my $type = ".*";
my $header = ".*";
my $value = ".*";
#$type = "CUSTOM|CHANNEL.*|MESSAGE";
#$header = "Core-UUID|Event-Subclass|Channel-State|Channel-Call-State";
#$value = "HANGUP|ACTIVE|DOWN|CS_EXECUTE";
my $con = new ESL::ESLconnection("localhost", "8021", "ClueCon");
$con->events("plain", "all");
while($con->connected()) {
my $e = $con->recvEvent();
if ($e) {
if(! ($e->getType() =~ /^($type)$/) ) {
next;
}
printf "Type: [%s]\n", $e->getType();
my $h = $e->firstHeader();
while ($h) {
if( ( $h =~ /^($header)$/) && ($e->getHeader($h) =~ ...