In this function (
|
func requestList(client Client, action, id, event, complete string, v ...interface{}) ([]Response, error) { |
) you are expecting that the next events after the action sent will we the ones related with that action, which could be not true: "At its heart, AMI is an asynchronous message bus: it spills events that contain information about the Asterisk system over some transport. In response, clients may request that Asterisk takes some action. These two concepts - actions and events - make up the core of what is AMI. As AMI is asynchronous, as events occur in Asterisk they are immediately sent to the clients. This means that actions issued by entities happen without any synchronization with the events being received, even if those events occur in response to an action. It is the responsibility of entities to associate event responses back to actions."
You should add that if the id of the event received is not equals to the one you sent in the action then discard the event as a response to that specific action.