简体   繁体   English

Asterisk 事件设备注册

[英]Asterisk Event Device Registration

I am trying to retrieve an event when a device registers an application using ARI.当设备使用 ARI 注册应用程序时,我正在尝试检索事件。 This can be assumed by changing the endpoint state from offline to online.这可以通过将端点 state 从离线更改为在线来假设。 The implementation that I have done in python is:我在 python 中完成的实现是:

self.client.on_event ('DeviceStateChanged', self.deviceRegistration)
self.client.on_event ('PeerStatusChange', self.deviceRegistration)
self.client.on_event ('EndpointStateChange', self.deviceRegistration)
self.client.on_event ('ContactStatusChange', self.deviceRegistration)

and nothing works.没有任何效果。 Anybody can help?有人可以帮忙吗?

I have managed to find a way to solve it.我已经设法找到解决它的方法。 The change of device state has listen by event EndpointStateChange.设备 state 的更改已通过事件 EndpointStateChange 进行侦听。 But before, we must subscribe our application to the stasis.但在此之前,我们必须为我们的应用程序订阅 stasis。 Here the implementation:这里的实现:

self.client = ari.connect(.....)    
self.client.applications.subscribe(applicationName="(our stasis name)",eventSource="endpoint:PJSIP")
self.client.on_endpoint_event('EndpointStateChange',self.handleDeviceRegister) 

where the handleDeviceRegister method are:其中handleDeviceRegister 方法是:

def handleDeviceRegister(self, channel_obj,ev):                
    if channel_obj.json["state"]=="online":            
        print "channel change from off to online"

if anybody get another way please tell me.如果有人得到另一种方式,请告诉我。 thanks谢谢

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM