Thread: Re: [Asterisk-java-users] Issue regarding streamfile on asterisk-java
Brought to you by:
srt
From: Stefan R. <ste...@re...> - 2007-11-22 22:15:00
Attachments:
signature.asc
|
Hi Noel, thanks for your feedback - and your english is not worse than mine *g* You can find our mailing lists at http://asterisk-java.org/development/mail-lists.html I cc'ed this reply to the -users list. I can understand that you want to handle the situation where the file is not available on the PBX but I have reservations regarding the solution you've proposed. The streamFile methods return a char and a char is defined as: "The char data type is a single 16-bit Unicode character. It has a minimum value of '\u0000' (or 0) and a maximum value of '\uffff' (or 65,535 inclusive)." so negative values are not allowed by the specification. What I could think of would be to throw an exception (but that would change the contract significantly). Any ideas? =3DStefan Noel R. Morais wrote: > Stefan, >=20 > I'm from Brazil and I use your library for integration with Asterisk AG= I. >=20 > Your library works gracefully and it attend all my requirements. > Thanks for the great job on it. >=20 > Well, there is a issue regarding the "streamFile(file, digits)" > command. I solved it and I want to share. >=20 > The AGI command "STREAM FILE <filename> <escape digits> [sample > offset]" returns: > failure: 200 result=3D-1 endpos=3D<sample offset> > failure on open: 200 result=3D0 endpos=3D0 > success: 200 result=3D0 endpos=3D<offset> > digit pressed: 200 result=3D<digit> endpos=3D<offset> >=20 > The library just return the result code, but in case of a stream file > of a file that doesn't exists it is going to return the wrong result > success. It should return a "failure on open" result. >=20 > So, I have changed the code of AgiChannelImp from: >=20 > public char streamFile(String file, String escapeDigits) > throws AgiException > { > AgiReply reply; >=20 > reply =3D sendCommand(new StreamFileCommand(file, escapeDigits)= ); > return reply.getResultCodeAsChar(); > } >=20 > To: >=20 > public char streamFile(String file, String escapeDigits) > throws AgiException > { > AgiReply reply; > int result; > reply =3D sendCommand(new StreamFileCommand(file, escapeDigits)= ); > result =3D (reply.getResultCode() =3D=3D 0 && reply.getAttribute("endp= os") > =3D=3D "0")? -2 : reply.getResultCodeAsChar() ; > return (char)result ; > } >=20 >=20 > Sorry about the really poor English and sorry about sending it to your > email but I didn't find any email-list or forum :( >=20 >=20 > Thanks in advance, >=20 > Noel --=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... Steuernummern 215/5140/1791 USt-IdNr. DE220701760 |
From: Noel R. M. <noe...@gm...> - 2007-11-22 22:59:12
|
Hi Stefan, I agree with you. I hadn't thought about the char :( Well, I have some ideas but all of them breaks the compatibility with the stable version :(. They are: - throwing a exception, as you said, is a good idea. - Changing the method return from char to String, or even to int. - Returning the AgiReply or creating a method that return the last result command (getLastResult) wouldn't break the compatibility with the stable version. What you think? Noel On Nov 22, 2007 8:14 PM, Stefan Reuter <ste...@re...> wrote: > Hi Noel, > > thanks for your feedback - and your english is not worse than mine *g* > You can find our mailing lists at > http://asterisk-java.org/development/mail-lists.html > I cc'ed this reply to the -users list. > > I can understand that you want to handle the situation where the file is > not available on the PBX but I have reservations regarding the solution > you've proposed. The streamFile methods return a char and a char is > defined as: > "The char data type is a single 16-bit Unicode character. It has a > minimum value of '\u0000' (or 0) and a maximum value of '\uffff' (or > 65,535 inclusive)." > so negative values are not allowed by the specification. > What I could think of would be to throw an exception (but that would > change the contract significantly). > Any ideas? > > =Stefan > > > > Noel R. Morais wrote: > > Stefan, > > > > I'm from Brazil and I use your library for integration with Asterisk AGI. > > > > Your library works gracefully and it attend all my requirements. > > Thanks for the great job on it. > > > > Well, there is a issue regarding the "streamFile(file, digits)" > > command. I solved it and I want to share. > > > > The AGI command "STREAM FILE <filename> <escape digits> [sample > > offset]" returns: > > failure: 200 result=-1 endpos=<sample offset> > > failure on open: 200 result=0 endpos=0 > > success: 200 result=0 endpos=<offset> > > digit pressed: 200 result=<digit> endpos=<offset> > > > > The library just return the result code, but in case of a stream file > > of a file that doesn't exists it is going to return the wrong result > > success. It should return a "failure on open" result. > > > > So, I have changed the code of AgiChannelImp from: > > > > public char streamFile(String file, String escapeDigits) > > throws AgiException > > { > > AgiReply reply; > > > > reply = sendCommand(new StreamFileCommand(file, escapeDigits)); > > return reply.getResultCodeAsChar(); > > } > > > > To: > > > > public char streamFile(String file, String escapeDigits) > > throws AgiException > > { > > AgiReply reply; > > int result; > > reply = sendCommand(new StreamFileCommand(file, escapeDigits)); > > result = (reply.getResultCode() == 0 && reply.getAttribute("endpos") > > == "0")? -2 : reply.getResultCodeAsChar() ; > > return (char)result ; > > } > > > > > > Sorry about the really poor English and sorry about sending it to your > > email but I didn't find any email-list or forum :( > > > > > > Thanks in advance, > > > > Noel > > > -- > 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... > > Steuernummern 215/5140/1791 USt-IdNr. DE220701760 > > |