On 7/26/07, Mark Webb <[EMAIL PROTECTED]> wrote:
I have seen the same thing on windows when using telnet using the MINA
EchoServer example program.  I think it is a windows, not MINA issue.

Yep.  Windows telnet client flushes every keystroke, while *NIX telnet
clients flush on a carrage return.

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;
>         }
>     }

You are using TextLineDecoder in a wrong way.  I'd suggest the
following implementation:

1) Use TextLineDecoder as it is; do not extend it.
2) Once you inserted your protocol codec filter, your IoHandler's
messageReceived() will be provided with a line of string.

HTH,
Trustin
--
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP Key ID: 0x0255ECA6

Reply via email to