[Asterisk-Dev] manager api and response data

francohit franco.baldi at hit.it
Mon Jun 13 03:55:08 MST 2005


For a presence application, I need to know the status (free, ringing,
talking) of the phones in the sip network managed by asterisk; to do this I
tried to use Manager Api. A little sample java program connects correctly
with Asterisk server and sends the commands to the engine; but when I look
at the response I see always a generic "success"; any action is then tracked
in the handleEvent function, but even here I can see only the event type,
the date, and no status info.
Where have I to look for the data? does exist a more complete code sample?
or any documentation, richer than the java docs?
thanks in advance,
Franco.
 
These are excerpts from the code and the resulting printout:  
----------------------
package ....
import ....
public class ProEvents implements ManagerEventHandler
{
......
    public void run() throws IOException, AuthenticationFailedException,
            TimeoutException, InterruptedException
    {
      managerconnection.addEventHandler(this);
      managerconnection.login();
      ManagerResponse managerresponse;
        ExtensionStateAction extensionstateaction = new
ExtensionStateAction();
        extensionstateaction.setExten("203");
        managerresponse = managerconnection.sendAction(extensionstateaction,
30000);
        System.out.println("response=" +
managerresponse.getAttribute("response"));
        System.out.println("status=" +
managerresponse.getAttribute("status"));
......
        StatusAction statusaction = new StatusAction();
        managerresponse = managerconnection.sendAction(statusaction, 30000);
        System.out.println("response=" +
managerresponse.getAttribute("response"));
        System.out.println("status=" +
managerresponse.getAttribute("status"));
......
      managerconnection.logoff();
    }
 
    public void handleEvent(ManagerEvent event)    {
        try { System.out.println(event.toString());   }
......
    }
 
    public static void main(String[] args) throws Exception    {
        ProEvents proevents = new ProEvents();
        proevents.run();
    }
}
---------------------
......
INFO: Connected via Asterisk Call
Manager/1.0net.sf.asterisk.manager.event.ConnectEvent: dateReceived=Mon Jun
13 11:36:49 
CEST 2005; systemHashcode=23047631
......
INFO: Successfully logged in

response=Success
status=-1
message=Extension Status
context=default
actionid=4898828_2#
exten=203
channel=null
 
net.sf.asterisk.manager.event.StatusCompleteEvent: dateReceived=Mon Jun 13
12:21:25 CEST 2005; systemHashcode=6166383
response=Success
status=null
message=Channel status will follow
context=null
actionid=4898828_3#
exten=null
 
net.sf.asterisk.manager.event.NewChannelEvent: dateReceived=Mon Jun 13
12:21:40 CEST 2005; systemHashcode=22323092
net.sf.asterisk.manager.event.NewExtenEvent: dateReceived=Mon Jun 13
12:21:40 CEST 2005; systemHashcode=17478435
net.sf.asterisk.manager.event.NewExtenEvent: dateReceived=Mon Jun 13
12:21:40 CEST 2005; systemHashcode=24569170
net.sf.asterisk.manager.event.NewExtenEvent: dateReceived=Mon Jun 13
12:21:40 CEST 2005; systemHashcode=5309741
net.sf.asterisk.manager.event.NewExtenEvent: dateReceived=Mon Jun 13
12:21:40 CEST 2005; systemHashcode=19583390
net.sf.asterisk.manager.event.NewExtenEvent: dateReceived=Mon Jun 13
12:21:40 CEST 2005; systemHashcode=2628939
net.sf.asterisk.manager.event.NewExtenEvent: dateReceived=Mon Jun 13
12:21:40 CEST 2005; systemHashcode=23994289
net.sf.asterisk.manager.event.NewExtenEvent: dateReceived=Mon Jun 13
12:21:42 CEST 2005; systemHashcode=14863189
net.sf.asterisk.manager.event.NewExtenEvent: dateReceived=Mon Jun 13
12:21:42 CEST 2005; systemHashcode=26435810
net.sf.asterisk.manager.event.NewExtenEvent: dateReceived=Mon Jun 13
12:21:43 CEST 2005; systemHashcode=12432643
net.sf.asterisk.manager.event.NewStateEvent: dateReceived=Mon Jun 13
12:21:43 CEST 2005; systemHashcode=11985823
......
net.sf.asterisk.manager.event.DisconnectEvent: dateReceived=Mon Jun 13
12:21:55 CEST 2005; systemHashcode=7056873
......
INFO: Closing socket.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.digium.com/pipermail/asterisk-dev/attachments/20050613/803f6c20/attachment.htm


More information about the asterisk-dev mailing list