java - best way to code for Netty FrameDecoder.decode -


i running problems coding framedecoder.decode() tcp netty client.

protected object decode(channelhandlercontext ctx, channel channel,         channelbuffer buffer) throws exception { 

in above signature , buffer supposed contain bytes need framed. why obejct have returned ? aware if returned object null , indicates more data required buffer, happens if return buffer unread bytes of partial frame in ? invoked more bytes added ?

lets given invocation of decode() has buffer 100 bytes in it. out of 100 , there 2 full frames of 25 , 55 bytes , partial frame of 20 bytes. can read first full frame ( of 25 bytes ) , return buffer ( 75 bytes in - 1 full frame of 55 bytes , 20 bytes of partial frame ) ? cause bytes overwritten next time decode invoked ? or ok me read next frame ( of 55 bytes ) in next invocation ?

you return 1 frame per each call of decode. framedecoder continue read , forward read frames until return null. bytes left in framedecoder saved , once new channelbuffer received both merged , framedecoders decode(..) method called again.


Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -