I am trying to retrieve an event when a device registers an application using ARI. This can be assumed by changing the endpoint state from offline to online. The implementation that I have done in python is:
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. But before, we must subscribe our application to the 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:
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.