2

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 ?

Devkil39
  • 81
  • 7

1 Answers1

0

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

Devkil39
  • 81
  • 7