Re: [Asterisk-java-users] Newbie Question
Brought to you by:
srt
From: Stefan R. <sr...@re...> - 2006-01-29 18:20:10
|
Hi, the data for agents is sent via events instead of as a reponse so you must send your your AgentsAction via sendEventGeneratingAction(). Example: AgentsAction agentsAction =3D new AgentsAction(); ResponseEvents responseEvents =3D=20 c.sendEventGeneratingAction(agentsAction, 30000); =20 for (ManagerEvent event :=20 (Collection<ManagerEvent>) responseEvents.getEvents()) { if (event instanceof AgentsEvent) { AgentsEvent agent =3D (AgentsEvent) event; System.out.println("Agent " + agent.getAgent() + ": " + agent.getStatus()); } } Hope that helps, Stefan On Wed, 2006-01-25 at 21:04 -0500, Yelson Vivas wrote: > HI Guys > I'm new in asterisk-java so sorry for the silly question. > I just wanna know the agents status in my pbx, but i don't know how to > get the info, the program connects fine to the pbx, but when i try to > read the data y don't know how, can you give me a hand?? > this is my code > -------------------------------------------------------------------------= ------------------------- > class definitions > -------------------------- > AgentsAction agac =3D new AgentsAction(); > Map datos ; > Collection datosp; > ---------------------------- > run method > ---------------------------- > ManagerResponse originateResponse; > managerConnection.login(); > originateResponse =3D managerConnection.sendAction(agac,4000); > System.out.println(originateResponse.getResponse()); > System.out.println(originateResponse.getMessage()); > System.out.println(originateResponse.toString()); > datos =3D originateResponse.getAttributes(); > datosp =3D datos.values(); > Iterator iter =3D datosp.iterator(); > while (iter.hasNext()){ > String agente =3D (String)iter.next(); > System.out.println("the data is '" + agente + "'"); > } > managerConnection.logoff(); >=20 > -------------------------------------------------------------------------= ------------------------- > The program shows this > -------------------------------------------------------------------------= ------------------------- >=20 > Jan 25, 2006 8:51:09 PM net.sf.asterisk.util.impl.JavaLoggingLog info > INFO: Connecting to 192.168.222.22 port 5038 > Jan 25, 2006 8:51:09 PM net.sf.asterisk.util.impl.JavaLoggingLog info > INFO: Connected via Asterisk Call Manager/1.0 > Jan 25, 2006 8:51:09 PM net.sf.asterisk.util.impl.JavaLoggingLog info > INFO: Successfully logged in > Jan 25, 2006 8:51:09 PM net.sf.asterisk.util.impl.JavaLoggingLog info > INFO: Determined Asterisk version: Asterisk 1.0 > Success > Agents will follow > net.sf.asterisk.manager.response.ManagerResponse: actionId=3D'null'; > message=3D'Agents will follow'; response=3D'Success'; uniqueId=3D'null'; > systemHashcode=3D1012673 > the data is '12014584_3#' > the data is 'Agents will follow' > the data is 'Success' > Jan 25, 2006 8:51:09 PM net.sf.asterisk.util.impl.JavaLoggingLog info > INFO: Reached end of stream, terminating reader. > Jan 25, 2006 8:51:09 PM net.sf.asterisk.util.impl.JavaLoggingLog info > INFO: Closing socket. > -------------------------------------------------------------------------= ------------------------------ > In other words how can i read the Map that should show me the agents stat= us??? > Thanks in advance > Best Regards > Yelson >=20 >=20 > ------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. Do you grep through log fi= les > for problems? Stop! Download the new AJAX search engine that makes > searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! > http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=103432&bid#0486&dat=121642 > _______________________________________________ > Asterisk-java-users mailing list > Ast...@li... > https://lists.sourceforge.net/lists/listinfo/asterisk-java-users |