Hi can you explain me how to properly send String through network and/or how to deal with fragmentation. As far i read some (not very informative) tutorials i still have some problems. I dont know why but some messages going through network(local) without problem and some doesnt. I found where the problem appears. Im trying to send 3 messages from server ( session.write(MessageA), session.write(MessageB), session.write(MessageC) ) to client. So when im sending MessageA which contains some Number values (int,long) it works fine, same with MessageB which contains few Number values and String, and when im sending MessageC which contains about 30 of Number values and String, its not always delivered. I tried to send only 2 combinations. MessageA and B works fine, rest MessageC + A or B dosnt and session is blocked( somehow , but i cant use it anymore, well im sending request but didnt get response which server sends) . With that MessageC all happens randomly.In one case im only get MessageC and after another request for these kind of data im get second message MessageB(or A) and again only MessageC. I believe it has something to do with fragmentation. Im extending CumulativeProtocolDecoder as a filter, it looks simple like this Enum as a messageType, then int as messageLength, and rest of data
Help ! doDecode() { if(in.prefixedData(1)) // reading enum { msgType = in.getEnum(...); switch(msgType) { if(in.prefixedData(4)) { dataLength = in.getInt(); if(in.remaining() >= dataLength) { // do decode break; // break switch loop } else { return false; } } else { return false; } } return true; } else { return false; } }