Teclo Perl Code Sample

Telco Code Sample

Tags:



Current Perl developers will find Telco Perl scripting simple and familiar, SkunkWorks says. The only difference, SkunkWorks says, is that all Telco Perl commands start with ``ww'' to indicate they are Whirlwind enabled.

As an example, here is a simple TelcoPerl script for handling an incoming call by answering it, playing a simple message and then hanging up.


eval {
wwTrace('on');
wwTraceFile('aph.pl.trace');
};

# get the necessary resources, fail with busy tone if no resources
exit if (wwResourceGet("vox", "player") < 0);

# let the call ring for 3 seconds then answer it
wwStartRinging();
sleep(3);
wwAnswerCall();

# play some audio
wwPlay("common/welcome");
wwPlay("aph/terminate");

# hangup the call
exit;

as

wwANSWER();
wwPLAY("welcome");

All Telco Perl commands start with ``ww'' to indicate they are Whirlwind enabled.

eval {
wwTrace('on');
wwTraceFile('mytrace.txt');
};
$hangup = sub {
if($child){
wwSendMsg($child, "goodbye", 0);
}
exit;
};
$goodbye = sub {
exit;
};
wwSetHandler($hangup, "hangup");
wwSetHandler($goodbye, "goodbye");
$child = wwStartService("demo", "out", "81234567", "81009000", "telstra", 1);
if($child <= 0){
exit;
}
while(1){
$msg = wwRecvMsg();
if($msg eq "ringing") {
wwGroupConnect($child);
}
if($msg eq "connected"){
sleep(60);
wwSendMsg("goodbye", $child);
exit;
}
if($msg eq "busy" || $msg eq "fail"){
exit;
}
}


back

Share
Go