Asterisk Perl AGI将不会继续

时间:2013-08-02 16:47:25

标签: perl asterisk agi

我可以接到运行AGI的呼叫,但是当我的Perl脚本运行循环时,我无法继续运行extensions.conf拨号计划。

所以我需要在拨打电话时在后台运行此AGI。

我的AGI部分搞砸了:

{
    my $linestatus = $agi->channel_status();

    ###THIS PART NEEDS TO LOOP UNTIL $linestatus == 6
    ###But It is also stopping the number from dialling.
    do{
    }
    until($linestatus == 6);

    my $query  = $collection->insert({
        caller     => $num,
        callername => $name,
        linestatus => $linestatus,
        extension  => $ext,
        call_start => $time }, {safe => 1});

    $agi->verbose("ANSWERED\n", 1);
}

我的extensions.conf拨号计划:

exten => _08.,1,AGI(bTel.agi)
exten => _08.,n,Dial(SIP/61${EXTEN:1}@SIPINTERNAL,,tTor)
exten => _08.,n,Hungup

1 个答案:

答案 0 :(得分:3)

如果

do{
}
until($linestatus == 6);

是代码的逐字副本,如果$linestatus开始处于错误状态,则循环无法终止,因为它的值在循环内不会发生变化。

相反,请使用

行中的代码
my $linestatus;
do {
    $linestatus = $agi->channel_status();
    sleep 1;  # or some other delay
} until (defined $linestatus && $linestatus == 6);