拨号计划执行顺序

发布于 2024-12-23 10:49:28 字数 697 浏览 3 评论 0原文

我的星号拨号计划中有以下上下文。

[start-call]
exten => _X.,1,AGI(agi://localhost:4000)
exten => _X.,n,GotoIf($["${AGISTATUS}" = "FAILURE"]?redirect)
exten => _X.,1000(redirect),Hangup(31)    
exten => 900,n,Goto(start-call,${EXTEN},1)
exten => h,n,Hangup

我有一个 AGI 应用程序,它连接呼叫并收集 DTMF 输入,并使用 SET EXTENSION agi 命令(第 1 行)将该号码设置为分机号。仅当没有 DTMF 输入时,我才将 AGISTATUS 设置为 FAILURE。如果没有输入,我就会超时并挂断(第 3 行)。但是,如果输入 900,我将返回到启动调用上下文,并在 AGI 应用程序中执行一些操作(第 4 行)。

问题是,现在即使我输入 900,电话也会挂断。不是从第 3 行开始,而是从最后一行开始。所以它以某种方式跳过了第 4 行。如果我将 900 分机(第 4 行)移到标记为 redirect 的分机(第 3 行)之前,它就会起作用。

我认为 asterisk 自动增加 'n' 优先级,并希望它按照上面列出的顺序工作。我这里错了吗?

I have the following context in my asterisk dialplan.

[start-call]
exten => _X.,1,AGI(agi://localhost:4000)
exten => _X.,n,GotoIf($["${AGISTATUS}" = "FAILURE"]?redirect)
exten => _X.,1000(redirect),Hangup(31)    
exten => 900,n,Goto(start-call,${EXTEN},1)
exten => h,n,Hangup

I have an AGI app which connects the call and collects DTMF inputs, and set that number as the extension using the SET EXTENSION agi command (line 1). I set the AGISTATUS to FAILURE only when there is no DTMF input. If there is no input, I timeout, and hangup (line 3). But if 900 is entered I go back to start-call context and do some magic in the AGI application (line 4).

The problem is that, right now even if I enter 900 the call just gets hung up. And not from line 3 but the last line. So its skipping line 4 somehow. If I move the 900 extension (line 4) before the one labelled redirect (line 3), it works.

I thought asterisk increments the 'n' priority automatically, and would expect this to work in the order listed above. Am I wrong here?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

神经大条 2024-12-30 10:49:28

n 自动迭代 - 它将 1 添加到前一个优先级。这也是为什么你必须在第一行初始化优先级为 1 的增量器。

当您将优先级 1000 放在中间的某个位置(这是完全有效的)时,下一行带有 n 的值将加 1,从而得到优先级 1001 - 正如其他人已经解释的那样,它永远不会被命中。

您的拨号方案可以如下所示:

[start-call]
exten => _X.,1,AGI(agi://localhost:4000)
exten => _X.,2,GotoIf($["${AGISTATUS}" = "FAILURE"]?redirect)
exten => _X.,1000(redirect),Hangup(31)    
exten => 900,1001,Something()                                          ; not 3!
exten => h,1,Hangup

要解决此问题,您必须按照其他人的说明重新排序您的分机,或者使用 + 运算符确定优先级:

[start-call]
exten => _X.,1,AGI(agi://localhost:4000)                               ; 1
exten => _X.,n,GotoIf($["${AGISTATUS}" = "FAILURE"]?redirect)          ; 2
exten => _X.,n+1000(redirect),Hangup(31)                               ; 1002
exten => 900,n,Something()                                             ; 3
exten => h,1,Hangup

顺便说一下,您还可以使用文本标签作为分机,这将使您的拨号计划更具可读性:

[start-call]
exten => _X.,1,AGI(agi://localhost:4000)                               ; 1
exten => _X.,n,GotoIf($["${AGISTATUS}" = "FAILURE"]?agi_failure,1)     ; 2
exten => 900,n,Something()                                             ; 3

exten => agi_failure,1,DoSomething()
exten => agi_failure,n,DoEvenMore()

exten => h,1,Hangup

n iterates automatically - it adds 1 to the previous priority. This is also why you have to initialize the incrementor with priority 1 in the first line.

When you put priority 1000 somewhere in the middle (which is totally valid) the next line with n will add 1 to this, resulting in priority 1001 - which is never hit as already explained by others.

Your dialplan can be read like below:

[start-call]
exten => _X.,1,AGI(agi://localhost:4000)
exten => _X.,2,GotoIf($["${AGISTATUS}" = "FAILURE"]?redirect)
exten => _X.,1000(redirect),Hangup(31)    
exten => 900,1001,Something()                                          ; not 3!
exten => h,1,Hangup

To fix this you must either reorder your extensions as explained by others or use the + operator for priorities:

[start-call]
exten => _X.,1,AGI(agi://localhost:4000)                               ; 1
exten => _X.,n,GotoIf($["${AGISTATUS}" = "FAILURE"]?redirect)          ; 2
exten => _X.,n+1000(redirect),Hangup(31)                               ; 1002
exten => 900,n,Something()                                             ; 3
exten => h,1,Hangup

By the way, you can also use text labels as extensions, which will make your dialplans more readable:

[start-call]
exten => _X.,1,AGI(agi://localhost:4000)                               ; 1
exten => _X.,n,GotoIf($["${AGISTATUS}" = "FAILURE"]?agi_failure,1)     ; 2
exten => 900,n,Something()                                             ; 3

exten => agi_failure,1,DoSomething()
exten => agi_failure,n,DoEvenMore()

exten => h,1,Hangup
锦欢 2024-12-30 10:49:28

拨号方案必须是连续的。 Ext 1000 永远不会被命中 - 因此星号会延伸到 h 扩展。

Dialplan must be consecutive. Ext 1000 is never hit - hence asterisk falls through to the h exten.

放我走吧 2024-12-30 10:49:28

是的,拨号方案必须是连续的,一旦开始“n”系列,您就需要坚持下去。我假设分机 900 是 DTMF 输入的一个示例 - 这个新分机必须始终以优先级 1 开头。“h”分机也必须以优先级 1 开头

[start-call]
exten => _X.,1,AGI(agi://localhost:4000)
exten => _X.,n,GotoIf($["${AGISTATUS}" = "FAILURE"]?redirect)
exten => _X.,n,**if input received do something here**
exten => _X.,n(redirect),Hangup(31)    

exten => 900,1,Goto(start-call,${EXTEN},1)
exten => h,1,Hangup

Yes the dialplan must be consecutive, and once you start the "n" series you need to stick with it. I am assuming extension 900 is an example of the DTMF input -- this new extension must always start with a priority of 1. The "h" extension must also start with a priority of 1

[start-call]
exten => _X.,1,AGI(agi://localhost:4000)
exten => _X.,n,GotoIf($["${AGISTATUS}" = "FAILURE"]?redirect)
exten => _X.,n,**if input received do something here**
exten => _X.,n(redirect),Hangup(31)    

exten => 900,1,Goto(start-call,${EXTEN},1)
exten => h,1,Hangup
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文