...
This guide provides a basic overview for handling call events and performing various actions (e.g., hangup) on calls.
The digium.event function is key to working with calls. When you register for an event that has to do with call creation, an eventData object is passed to your handler that provides a variety of information. Most important is the callHandle. Here is an example of the eventData from an incoming call.
Code Block |
---|
{ "eventName":"digium.phone.incoming_call", "eventData":{ "state":"INCOMING", "accountSlot":"0", "callHandle":"319-5", "remoteInfo":"\"Princess Peach\" <sip:101@10.10.8.218>", "remoteContact":"<sip:101@10.10.8.218>", "lastStatus":"0", "lastStatusText":"", "mediaStatus":"none", "headers":{"Via":"SIP/2.0/UDP 10.10.8.218:5060;rport=5060;received=10.10.8.218;branch=z9hG4bK1a83d2ea", "From":"\"Princess Peach\" <sip:101@10.10.8.218>;tag=as486547c6", "To":"<sip:200@10.10.6.193;ob>", "Contact":"<sip:101@10.10.8.218>", "Call-ID":"0d82476949832b7b6974c23e107cd479@10.10.8.218", "CSeq":"102 INVITE","User-Agent":"Asterisk PBX (digium)", "Max-Forwards":"70","Date":"Tue, 12 Mar 2013 05:11:58 GMT", "Allow":"INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO", "Supported":"replaces", "Content-Type":"application/sdp", "Content-Length":"288"}, "role":"callee","local_info":"<sip:200@10.10.6.193;ob>", "local_contact":"\"200\" <sip:200@10.10.6.193:5060;ob>", "connect_duration":"0", "account_subslot":"0" },"messageId":"ae277800"} |
Code Block |
---|
The digium.phone function provides a set of useful methods for working with calls. You can do things such as answer, hangup, and dial. Dial is used for starting a call, and the rest can be used to handle an existing call. The following example shows the process of observing a call, handling the response, and performing actions on the call itself.
...