Re: [Asterisk-java-users] Problems with CommandAction
Brought to you by:
srt
From: Bruno K. <bru...@un...> - 2008-02-02 13:24:47
|
Stefan, thanks. I think I am using it the right way : commandAction =3D new CommandAction("dialplan show"); response =3D managerConnection.sendAction(commandAction); if (response instanceof CommandResponse) { Iterator<String> i =3D ((CommandResponse) response).getResult().iterator(); while (i.hasNext()) { String item =3D i.next(); } } and yes I am using the 1.0.0 snapshot from last thursday. Bruno 2008/2/1, Stefan Reuter <ste...@re...>: > > Do you use this correctly? > Example: > response =3D sendAction(new CommandAction(command)); > if (!(response instanceof CommandResponse)) > { > throw new ManagerCommunicationException( > "Response to CommandAction(\"" + command > + "\") was not a CommandResponse but " + > response, > null); > } > > // use ((CommandResponse) response).getResult(); > > getResult() returns a List of Strings - one per line. > > Besides, the implementation has been completly reworked in svn trunk to > use \r\n as delimiter so that newlines in the responses do work without > additonal hacks. > Would you mind to check svn trunk or the latest 1.0.0 snapshot? > > =3DStefan > > > > Bruno Konik wrote: > > Hello, > > > > Asterisk 1.4.17, > > Asterisk-java 0.3.1 > > > > I am trying to use the CommandAction with 'diaplan show' but the > response gives only the last line of the response. It seems that > > the Reader doesn't allow to give such responses splitted over several > lines. > > > > If you accept a modification to treat it I suggest the following code i= n > the ManagerReaderImpl.java : > > > > StringBuilder commandResponseResult =3D null; // the buffer to be > used for multi lines command response > > while ((line =3D socket.readLine()) !=3D null && !this.die) > > { > > ... > > > > // your code was : > > // Special handling for "Response: Follows" (CommandResponse) > > // if ("Follows".equals(buffer.get("response")) && > line.endsWith("--END COMMAND--")) > > // { > > // buffer.put("result", line); > > // continue; > > // } > > > > // I suggest : > > // special handling for "Response: Follows" (CommandResponse) to treat > several lines > > // START > > if ("Follows".equals(buffer.get("response")) && > line.length() > 0 && buffer.containsKey("actionid")) > > { > > if (commandResponseResult =3D=3D null) { > > if (line.endsWith("--END COMMAND--")) { > > buffer.put("result", line); > > } else { > > commandResponseResult =3D new StringBuilder(line)= ; > > } > > } else { > > commandResponseResult.append(line); > > if (line.endsWith("--END COMMAND--")) { > > buffer.put("result", > commandResponseResult.toString()); > > commandResponseResult =3D null; > > } > > } > > continue; > > } > > // END > > ... > > > > Thanks for letting me know if you are ok with that and thanks for your > help, > > > > Bruno Konik > > > >> -----Message d'origine----- > >> De : ast...@li... > >> [mailto:ast...@li...] De > >> la part de Stefan Reuter > >> Envoy=E9 : mardi 2 octobre 2007 02:44 > >> =C0 : ast...@li... > >> Objet : Re: [Asterisk-java-users] asterisk java and astmanproxy > >> > >> Ga=EBtan Minet wrote: > >>> Here is a link > >>> > >>> http://dev.mcit.be/various/astmanproxy-asterisk-java.html > >> Thanks. You'll find the link on the A-J homepage. I've also > >> added it to the AstManProxy page on voip-info.org. > >> > >> Support for the server property is now in SVN. > >> > >> =3DStefan > >> > >> > > > > > > > > > ------------------------------------------------------------------------- > > This SF.net email is sponsored by: Microsoft > > Defy all challenges. Microsoft(R) Visual Studio 2008. > > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > > _______________________________________________ > > Asterisk-java-users mailing list > > Ast...@li... > > https://lists.sourceforge.net/lists/listinfo/asterisk-java-users > > > -- > reuter network consulting > Neusser Str. 110 > 50760 Koeln > Germany > Telefon: +49 221 1305699-0 > Telefax: +49 221 1305699-90 > E-Mail: ste...@re... > Jabber: ste...@re... > WWW: http://www.reucon.com > > Steuernummern 215/5140/1791 USt-IdNr. DE220701760 > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > Asterisk-java-users mailing list > Ast...@li... > https://lists.sourceforge.net/lists/listinfo/asterisk-java-users > > > |