Please forgive wonky capitals.  I'm having to type this from computer to 
computer.  No exceptions are being recorded.  No exceptions are being caught.

It's definitely not the prettiest code and needs cleaning, but I am unable to 
track down why the connection is closing here.

Thank you for your help.

public class CodecFactory extends TextLineEncoder implements 
ProtocolCodecFactory {
        public static String EOM = "//endmsg//";
        public static String BOM = "//stmsg//";

        public ProtocolEncoder getEncoder(IoSession ioSession) {
                return (ProtocolEncoder) new CustomEncoder();
                }

        public ProtocolDecoder getDecoder(IoSession ioSession) {
                return (ProtocolDecoder) new CustomDecoder();
        }
}

Public class CustomDecoder extends CumulativeProtocolDecoder {
///
Public Boolean doDecode(<args>) throws Exception {
        Try { 
                Int startPosition = ioBuffer.position();
                Boolean receivedEndSequence = false;
                
                StringBuffer buffer = new StringBuffer();
                while (ioBuffer.hasRemaining()) {
                        byte by = ioBuffer.get();
                        buffer.append((char)b);
                        if (buffer.toString().endWith(CodecFactory.EOM)) {
                                receivedEndSequence = true;
                        }
                }
                if (receivedEndSequence && ioBuffer.hasRemaining()) {
                        //logging
                        out.write(fullMessage);
                        return true;
                }
        }
        Catch (Exception e) {
                //logging
        }
}
}

public class CustomEncoder extends protocolEncoderAdapter {
        public void encode(<args>) {
                IoBuffer buf = IoBuffer.allocate(1, false);
                buf.setAutoExpand(true);
                buf.putString(CodecFactory.BOM);
                buf.putString(message.toString(), 
Charset.forName("ASCII").newEncoder());
                buf.putString(CodecFactory.EOM);
                buf.flip();
                out.write(buf);
        }
}

-----Original Message-----
From: Emmanuel Lécharny [mailto:[email protected]] 
Sent: Monday, May 13, 2013 4:18 PM
To: [email protected]
Subject: Re: Help with NioSocketConnector

Le 5/13/13 8:45 PM, Whitener, Winona T. a écrit :
> Hello,
>
> I think that (pending more strenuous testing), I have found the problem.  I 
> have a portion of the written message that is "AAC".  When I change this to 
> "AAR" or "AAB" or just about any other combination of letter, I can get the 
> message through.  I don't know why "AAC" is the problem.  Are there other 
> abbreviations or strings that are problematic?
Nope. Again, there is something in your codec that should consider those 
strings as unexpected.

Nothing beats thourough unit testing :-)


--
Regards,
Cordialement,
Emmanuel Lécharny
www.iktek.com 

Reply via email to