Asterisk-java AMI2 Event Monitoring

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.