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.