0

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

所以我需要在拨打电话时在后台运行这个 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
4

1 回答 1

3

如果

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

是您的代码的逐字副本,那么如果以错误的状态开始,循环将无法终止,$linestatus因为它的值在循环内不会改变。

相反,使用代码

my $linestatus;
do {
    $linestatus = $agi->channel_status();
    sleep 1;  # or some other delay
} until (defined $linestatus && $linestatus == 6);
于 2013-08-02T17:20:27.633 回答