So considering your answer it seems that all is fine, but it isnt. So can you show me example how will you do it(local on windows). I mean decoding,encoding,charset type for two messages 1st String + two ints , 2nd String + long. And you will be sure that it working 100%. Im running out of ideas...
2012/1/24 Emmanuel Lécharny <elecha...@apache.org> > On 1/24/12 5:42 PM, Robert Tomczyk wrote: > >> So this how i see it. >> Every step i make in decoder i mean: >> if(in.prefixedData(x)) // one step = decode next "element" >> i have to put this data in my DecoderState for specific kind of data ? >> i.e. >> MessageAstate,MessageXstate etc. >> and if next step will return false. Then decoder will be executed again >> and >> as in example i will check my specific decoder what kind of data should i >> "load" (in.getSomething()). Do i get it right ? >> > > Looking at your code, it seems that the doDecode() method is correct. > > Basically, what you do for each data structure in your message is : > > if (I have N bytes in the stream where N is the number of bytes I need > for the data structure I will read) > then > continue with the next bytes > else > return false // will wait until enough data is coming > > until you have completed the decoding. That's fine, because you always > check that you will be able to read an enum (1 byte), an integer (4 bytes) > etc. > > Also note that you will start over from the beginning until you have > enough bytes in the IoBuffer (the IoBuffer will be expanded to receive the > extra bytes until the doDecode method returns true) > > For Strings, you should be careful though : the String <-> bytes > conversion has to take care of the encoding. On one computer, if you just > do something like myString.getBytes(), you will get the bytes using a local > encoding (ISO-8859-1 on Windows, but most certainly UTF-16 on linux, or > something else, depending on your local env). The best is to decode using > one specific encoding. > > > > > -- > Regards, > Cordialement, > Emmanuel Lécharny > www.iktek.com > >