Hi, it's seems that not either reason to cause this happen, my encoder look
like this,
I ever try to catch exception but no exception happen, thanks a lot... 

public class LengthDataEncoder implements ProtocolEncoder {
        private int lengthSize = 4;

        public LengthDataEncoder(int lengthSize) {
                this.lengthSize = lengthSize;
        }
        
        public void dispose(IoSession session) throws Exception {
                // TODO Auto-generated method stub
        }

        public void encode(IoSession session, Object message, 
ProtocolEncoderOutput
out)
                        throws Exception {
                // TODO Auto-generated method stub
                System.out.println("LengthDataEncoder");
                StringBuilder sb = new StringBuilder("%0");
                sb.append(lengthSize);
                sb.append("d");
                IoBuffer rb = (IoBuffer) message;
                int msgLen = rb.remaining();
                IoBuffer wb = IoBuffer.allocate(msgLen+lengthSize, false);
                wb.put(String.format(sb.toString(), msgLen).getBytes());
                wb.put(rb);
                wb.flip();
                out.write(wb);
        }
}


Trustin Lee wrote:
> 
> On 11/6/07, liquidchen <[EMAIL PROTECTED]> wrote:
>>
>> Hi, I write a Protocol Encoder and Decoder to receive and send length
>> data
>> message, decoder will receive all message by length, and encoder will add
>> length data for remote
>> client, and I find that the decoder will be fire when message incoming,
>> but
>> when I send the
>> message to remote site, I find that the encoder not be fire, do anyone
>> know
>> what may cause
>> this happen?? Thanks...
> 
> Probably because:
> 
> * your encoder didn't call ProtocolEncoderOutput.write(),
> * or your encoder raised an exception and you didn't notice it.
> 
> I don't have much clue considering the amount of information you provided.
> 
> Trustin
> -- 
> what we call human nature is actually human habit
> --
> http://gleamynode.net/
> --
> PGP Key ID: 0x0255ECA6
> 
> 

-- 
View this message in context: 
http://www.nabble.com/strange-thing-that-Codec-Encoder-not-fire-tf4755629s16868.html#a13599922
Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.

Reply via email to