Closed ghost closed 6 years ago
I want write something to help collect events generated by an action, but I don't have time at the moment.
I think you can write something like that for while:
from asterisk.ami import AMIClient
from asterisk.ami import SimpleAction
client = AMIClient(address='127.0.0.1',port=5038)
client.login(username='username',secret='password')
events = []
def event_listener(event,**kwargs):
events.append(event)
client.add_event_listener(event_listener, white_list=['EndpointDetail'])
action = SimpleAction(
'PJSIPShowEndpoint',
Endpoint='test'
)
res = client.send_action(action).response
print(events)
add_event_listener does not catch all the events in the successful action, I am initiating Originate action but none of the events is caught in the case of a successful dial and action exits without waiting for the hangup event in the synchronous call.
I don't know what is the problem, can you show some code?
@adeshpandey No, that's not how it works. For hangup you can catch event Hangup. Close this.
My code:
How to access the response at
print(event)
? I want to access the returned data in the main thread.