Asteriskserver Article 1 mentions how to obtain, does not explain
Asteriskserver.addchainlistener (New Asteriskeventlistenerinit ());//The whole service of event monitoring, to this service plus monitoring
By implementing the Managereventlistener class,
public class Asteriskeventlistenerinit implements Managereventlistener {
@Override
public void Onmanagerevent (Managerevent event) {
Here you can get the parameters returned by the event, get the type can be miserable open API document
Domo
Return SIP Extension End Event
}else if (event instanceof Peerlistcompleteevent) {
Peerlistcompleteevent perrs= (peerlistcompleteevent) event;
Mapcacheutil instance=mapcacheutil.getinstance ();
if (Perrs.getactionid ()!=null) {
Instance.putperrslist (Perrs.getactionid (), Instance.getperrs (Perrs.getactionid ()));//Get the whole event over
}
The SIP extension Information event is returned
}else if (event instanceof Peerentryevent) {
Peerentryevent pentry= (peerentryevent) event;
Mapcache.putextensions (Pentry.getobjectname ());//storage of all extension containers, used to determine that the extension does not need to play screen
if (Pentry!=null && pentry.getstatus ()!=null) {
if (Pentry.getstatus (). Contains ("OK") &&! String.valueof (Pentry.getport ()). Equals ("0")) {
List Actionidoldlist=mapcache.getactionid ();
if (actionidoldlist!=null) {
for (int i=0;i<actionidoldlist.size (); i++) {
String Actionid=pentry.getactionid ();
if (! Toolutils.checknull (ActionId) && actionid.equals (Actionidoldlist.get (i))) {
if (Toolutils.isinteger (Pentry.getobjectname ())) {//Extension number is numeric type put in
Mapcache.putperrs (ActionId, Pentry.getobjectname ());
}
}
}
}
Perrlist.add (Pentry.getobjectname ());
}
}
Returns the Hanging information event
}else if (event instanceof Hangupevent) {
Hangupevent hangup= (hangupevent) event;
New WebSocket (). Broadcast ("WebSocket" +baseutil.getnumber (Hangup.getchannel ()), "Mount Reason:" +baseutil.gethangup ( Integer.valueof (Hangup.getcause ()). Intvalue ());
Extension status Change Event
}else if (event instanceof Extensionstatusevent) {
Extensionstatusevent extensionstatus= (extensionstatusevent) event;
Jsonobject jsono=new jsonobject ();
Jsono.put ("id", Extensionstatus.getexten ());
Jsono.put ("Statusname", Baseutil.getextensionstate (Extensionstatus.getstatus ()));
New WebSocket (). Broadcastall (Jsono);
Call hold event for the time being
}else if (event instanceof Parkedcallevent) {
Parkedcallevent parkcall= (parkedcallevent) event;
String Key=baseutil.getnumber (Parkcall.getfrom ());
Key+=baseutil.channelpark_centent;
Mapcache.put (Key, Parkcall.getexten ());
Get Database Data Events
}else if (event instanceof Dbgetresponseevent) {
Dbgetresponseevent dbget= (dbgetresponseevent) event;
}else if (event instanceof Disconnectevent) {
Disconnectevent disconn= (disconnectevent) event;
SYSTEM.OUT.PRINTLN ("Connection asterisk service failed event triggered:" +disconn);
All results return events, written in the last
}else if (event instanceof Responseevent) {
Responseevent response= (responseevent) event;
}
}
}
Asterisk-java AMI2 Event Monitoring