I've seen this on Windows telnet as well. It seems to send characters
as soon as you type them without waiting for you to press ENTER. But I
obviously know nothing about the technical answer to that question :-D

On 7/25/07, alimli <[EMAIL PROTECTED]> wrote:

Hi,
First, I want to mention that I'm new to Java. So I'm asking some silly
question don't blame me. :)

I wrote a subclass of TextLineDecoder and override decode function. Code
looks like below

public class CaiRequestDecoder extends  TextLineDecoder {

   private CharsetDecoder _decoder = Charset.forName("ASCII").newDecoder();

   /** Creates a new instance of CaiRequestDecoder */
   public CaiRequestDecoder() {
       super(Charset.forName("ASCII"), LineDelimiter.MAC);
   }

   public void decode(IoSession session, ByteBuffer in,
           ProtocolDecoderOutput out) throws Exception {
       // Try to decode body
       try {
           CaiRequestMessage m = decodeBody(in);
           out.write(m);
       } catch(ProtocolDecoderException ex) {
//            session.write("RESP-1").join();
//            session.close();
       }
   }

   private CaiRequestMessage decodeBody(ByteBuffer in) throws
ProtocolDecoderException  {
       String inStr = "";
       try {
           inStr = in.getString(_decoder);
           System.out.println("Buffer String :" + inStr);
           CaiRequestMessage request = parseRequest(new
StringReader(inStr));
           return request;
       } catch (CharacterCodingException ex) {
           ex.printStackTrace();
           return null;
       }
   }

When I telnet my application for testing from a Solaris machine, I type the
input and press enter. Then my decode function is called. All is fine.

But when I try to telnet from windows and type sth. Every key triggers my
decode function. And HeapBuffer's limit is always 1. Only the last character
is returned from in.getString();

Is it sth. wrong with my code? I expect TextLineDecoder will only call
decode when a line is completed? Isn't this the default behaviour?

Thanks.
--
View this message in context: 
http://www.nabble.com/TextLineDecoder-decode-function-tf4142835s16868.html#a11784785
Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.


Reply via email to