[Asterisk-Dev] manager api and response data

Moises Silva moises.silva at gmail.com
Mon Jun 13 08:58:23 MST 2005


Hi Franco. I have a PHP script that connects successfully and receives
the responses correctly. I think that it would help you to read the
manager.c file in the Asterisk source code. Also, its difficult to
know why you are not getting the whole response from asterisk, since
the code you show us does not allow us to see how is making the socket
connection and how is reading the response, in other words, the class
of the object managerconnection is what you should post if possible.

best regards

On 6/13/05, francohit <franco.baldi at hit.it> wrote:
>  
> 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.
>  
> _______________________________________________
> Asterisk-Dev mailing list
> Asterisk-Dev at lists.digium.com
> http://lists.digium.com/mailman/listinfo/asterisk-dev
> To UNSUBSCRIBE or update options visit:
>    http://lists.digium.com/mailman/listinfo/asterisk-dev
> 
> 


-- 
"Su nombre es GNU/Linux, no solamente Linux, mas info en http://www.gnu.org"



More information about the asterisk-dev mailing list