You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by liquidchen <li...@gmail.com> on 2007/11/06 02:55:32 UTC
strange thing that Codec Encoder not fire
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...
--
View this message in context: http://www.nabble.com/strange-thing-that-Codec-Encoder-not-fire-tf4755629s16868.html#a13599450
Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.
Re: strange thing that Codec Encoder not fire
Posted by Trustin Lee <tr...@gmail.com>.
Please create a JIRA issue which is attached with a reproduceable and
runnable code by ourselves.
Trustin
On 11/6/07, liquidchen <li...@gmail.com> wrote:
>
> 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 <li...@gmail.com> 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.
>
>
--
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP Key ID: 0x0255ECA6
Re: strange thing that Codec Encoder not fire
Posted by liquidchen <li...@gmail.com>.
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 <li...@gmail.com> 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.
Re: strange thing that Codec Encoder not fire
Posted by Trustin Lee <tr...@gmail.com>.
On 11/6/07, liquidchen <li...@gmail.com> 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