[Asterisk-Dev] AMI question

snacktime snacktime at gmail.com
Sat Oct 15 00:32:24 MST 2005


Couple more quick questions.

Events generated in response to an action contain a unique id but not the
associated action id. I take it this is because the action id isn't
available to whatever part of the code actually generated the event?

The main challenge I am having with this interface is matching up events
with the actions that generated them, primarily when calling Originate. The
best thing I have found so far is to look at each action and it's events and
find something that is known when the action is called, and is also present
in every event generated by that action.

Right now the proxy server has one main thread that reads responses from
asterisk, and a thread for each client that connects to the proxy. The main
server thread puts all event responses into one queue, and all other
responses into another queue (the state queue and action queue). The action
queue is presumably responses which have an action id.

Connecting as a client is done via a ruby module that provides methods for
particular actions.

For actions where the response will contain an action id, the client waits
until the response is received or a timeout is reached. For actions that
generate events, the client connects, sends the action, and then
disconnects.

The client can then use methods for searching the state queue for events
it's interested in, or a method which just gives it the contents of the
entire queue. The search method takes a hash and searches for events in the
state queue with matching key/value pairs. Rather than do something like
hardcode in Channel as the key to determine events that match an Originate
action, I decided to leave it up to the user, with some notes on what seems
to work.

If anyone has any thoughts or input on this structure please let me know.
I'll be releasing it under a BSD license once it get it wrapped up.

Chris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.digium.com/pipermail/asterisk-dev/attachments/20051015/ff8e34eb/attachment.htm


More information about the asterisk-dev mailing list