The AMI (Asterisk Manager Interface) Proxy suite project will bridge the gap between your asterisk phone system and your windows based applications.
The AMI Proxy is a service that can be used to simply proxy AMI connections to your asterisk server but also adds call stat generation and line monitors.
This is the main service that will run on your windows machine. All clients will connect to this service.
AMI Proxy Logic
The core of the AMI Proxy lies here. When you connect to the AMI Proxy you can send messages to control what messages are sent back to your client.
- Command: AMIProxy
- Command: CallStat
- Command: PhoneStateMonitor
- Command: Listen
This command will relay every single message that is sent from the asterisk AMI server to your client, with only one exception. When sending in messages for the asterisk server to action those messages are only sent back to the original caller.
So for example, you have 5 clients connected to the AMI Proxy and one of them issues the Action "sippeers". This will get asterisk return a full list of all of its SIP peers. The AMI Proxy will automatically give this action an ActionID (if it is
missing in the original request) or update the supplied action ID with the sockets ID. When a message is sent back from the asterisk AMI the system checks the actionID to correctly route it back to the correct connection.
AMI Proxy also uses the messages from the asterisk AMI to collate its own call stats. When you send the AMI Proxy the Command "callStat" the client will receive these messages. You can use these messages to create your own call stat logic or use the
AMICallStaticLogic library to manage these messages for you and return new call stat information as an event.
PhoneStateMonitor will return messages which summaries the status of a phone on the system. The AMI Proxy uses the same messages returned from the asterisk AMI to determine if a phone is in the following 3 states.
No channels are on the phone
The phone has an active channel (on a connected call) or the user of the phone has dialed out and the line is ringing
The phone has an incoming call
The Listen command will return you detailed information about an extension and its state. For example, how many channels the phone currently has and each channel status. (Onhold, Active, ringing).
We use the messages sent from the asterisk AMI to update the channel with information not easily obtainable like the original caller ID of an incoming call (which updates post transfers). Using the AMI Proxy Phone Client Logic library is the simplest way to
make sense of the listen command and will turn all this information into strongly typed classes using events.