Re: [Asterisk-java-users] Problems with CommandAction
Brought to you by:
srt
From: Stefan R. <ste...@re...> - 2008-02-01 18:06:41
|
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, >=20 > Asterisk 1.4.17, > Asterisk-java 0.3.1 >=20 > I am trying to use the CommandAction with 'diaplan show' but the respon= se gives only the last line of the response. It seems that > the Reader doesn't allow to give such responses splitted over several l= ines.=20 >=20 > If you accept a modification to treat it I suggest the following code i= n the ManagerReaderImpl.java : >=20 > StringBuilder commandResponseResult =3D null; // the buffer to be= used for multi lines command response=20 > while ((line =3D socket.readLine()) !=3D null && !this.die) > { > ... >=20 > // your code was : > // Special handling for "Response: Follows" (CommandResponse) > // if ("Follows".equals(buffer.get("response")) && line.= endsWith("--END COMMAND--")) > // { > // buffer.put("result", line); > // continue; > // } >=20 > // I suggest : > // special handling for "Response: Follows" (CommandResponse) to treat = several lines > // START > if ("Follows".equals(buffer.get("response")) && line.le= ngth() > 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 > ... >=20 > Thanks for letting me know if you are ok with that and thanks for your = help, >=20 > Bruno Konik >=20 >> -----Message d'origine----- >> De : ast...@li...=20 >> [mailto:ast...@li...] De=20 >> 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=20 >> added it to the AstManProxy page on voip-info.org. >> >> Support for the server property is now in SVN. >> >> =3DStefan >> >> >=20 >=20 >=20 > -----------------------------------------------------------------------= -- > 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 --=20 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 |