Message to Netty Server sometimes gets lost

NettyMW a2642372 at bofthew.com
Mon Jul 12 15:42:22 EDT 2010


Hi Trustin! Thank you!

The ChannelPipelineFactory's getPipeline Method:
 
public ChannelPipeline getPipeline() throws Exception {
        ChannelPipeline pipeline = Channels.pipeline();

        pipeline.addLast("ChannelHandler", new ChannelHandler());

        return pipeline;
}


I understand, but how can i ensure that all data is consumed by the decoder
and whats the correct way to handle the remaining bytes over to the next
decoder? The decode Method of the XDecoder looks like:


public class XDecoder extends ReplayingDecoder<State> { ...

@Override
protected Object decode(ChannelHandlerContext ctx, Channel channel,
            ChannelBuffer buffer, State state) {

// Read some byte:
CommandType command = readCommand(buffer);

switch (command) {
...
    case COMMAND_A:
      // Here i add the new YDecoder:
      ctx.getPipeline().addAfter("XDecoder", command.toString() + "Decoder",
new YDecoder());
      break;
...
}

// Then i remove the XDecoder with:
ctx.getPipeline().remove(this);

// Finally i send the data to the YDecoder:
if (buffer.readable()) {
  return new Object[]{command,
buffer.readBytes(super.actualReadableBytes())};
} else {
  return command;
}

...



The YDecoder and the ZDecoder (which should receive the Statuscode) are not
explicitly removed. 

Best Regards, Michael 




-- 
View this message in context: http://netty-forums-and-mailing-lists.685743.n2.nabble.com/Message-to-Netty-Server-sometimes-gets-lost-tp5279786p5284536.html
Sent from the Netty User Group mailing list archive at Nabble.com.


More information about the netty-users mailing list