gpt4 book ai didi

asterisk - 如何从 Asterisk REST API (ARI) 获取所有拨号事件?

转载 作者:行者123 更新时间:2023-12-04 22:04:23 26 4
gpt4 key购买 nike

我正在制作一个 Web 应用程序,它应该能够监视我的 Asterisk 服务器上的调用。我可以通过 URL ws://(host):8088/ari/events?app=dialer 上的 Javascript WebSocket 连接到 ARI它有效。问题是我只能从通过 ARI 进行的调用中获取事件。从其他客户端(如 Zoiper)发出的调用未注册。另一方面,Asterisk 有 AJAM,它在 http://(host):8088/rawman?action=waitevent 上使用长轮询。它注册来自所有客户端(ARI、Zoiper 和其他)的调用,但只有信息 正在调用(来电者),而不是 (被叫方)。

所以,我的问题是,我怎样才能获得实时调用事件,显示谁在调用谁,来自所有客户端,(最好)使用 WebSockets。谢谢。

最佳答案

ARI 使用基于订阅的事件模型。引用 wiki 上的文档:

Resources in Asterisk do not, by default, send events about themselves to a connected ARI application. In order to get events about resources, one of three things must occur:

  1. The resource must be a channel that entered into a Stasis dialplan application. A subscription is implicitly created in this case. The subscription is implicitly destroyed when the channel leaves the Stasis dialplan application.
  2. While a channel is in a Stasis dialplan application, the channel may interact with other resources - such as a bridge. While channels interact with the resource, a subscription is made to that resource. When no more channels in a Stasis dialplan application are interacting with the resource, the implicit subscription is destroyed.
  3. At any time, an ARI application may make a subscription to a resource in Asterisk through application operations. While that resource exists, the ARI application owns the subscription.


因此,您通过 ARI WebSocket 获取有关 channel 的事件的原因是它进入了 Stasis 拨号计划应用程序。然而,这并不是获取事件的唯一方法。

如果您对来自其他事件源的事件感兴趣,可以使用 applications 订阅这些资源。资源。例如,如果我想接收与 PJSIP 端点“Alice”相关的所有事件,我将使用以下内容进行订阅:
POST https://localhost:8080/ari/applications/my_app/subscription?eventSource=endpoint:PJSIP%2FAlice

请注意,对端点的订阅隐式地为您订阅了为该端点创建的所有 channel 。如果要订阅特定技术的所有端点,也可以订阅资源本身:
POST https://localhost:8080/ari/applications/my_app/subscription?eventSource=endpoint:PJSIP

关于asterisk - 如何从 Asterisk REST API (ARI) 获取所有拨号事件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28064526/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com