2013-10-14 2 views
0

Я обновляю свои фреймворки Netty-версию до новейшей версии, и кажется, что API сломался (я знаю, что я не должен был использовать его до тех пор, пока не закончится окончательная версия); Я читал документы и просматривал классы, чтобы попытаться найти приемлемое решение, но я не могу его найти.Преобразование из Netty 4.0 CR3 в 4.0.10-final

ctx.nextInboundMessageBuffer().add(message); 
    ctx.fireInboundBufferUpdated(); 

    if (additionalBuf != null) { 
     ChannelHandlerContext head = ctx.pipeline().firstContext(); 
     head.nextInboundByteBuffer().writeBytes(additionalBuf); 
     head.fireInboundBufferUpdated(); 
    } 

Является тем, что я пытаюсь преобразовать в новый API, любая помощь приветствуется.

Полный код:

@Override 
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception { 
    if (!in.isReadable()) { 
     return; 
    } 

    int messageId = in.readUnsignedByte(); 

    ByteBuf additionalBuf = null; 
    if (in.isReadable()) { 
     additionalBuf = in.readBytes(in.readableBytes()); 
    } 

    ChannelPipeline pipeline = ctx.pipeline(); 
    pipeline.remove(HandshakeDecoder.class); 

    HandshakeMessage message = HandshakeMessage.forId(messageId); 

    switch (message) { 
    case LOGIN_MESSAGE: 
     break; 
    case UPDATE_MESSAGE: 
     break; 
    default: 
     throw new IllegalStateException("Unexpected message id: " + messageId); 
    } 

    ctx.nextInboundMessageBuffer().add(message); 
    ctx.fireInboundBufferUpdated(); 

    if (additionalBuf != null) { 
     ChannelHandlerContext head = ctx.pipeline().firstContext(); 
     head.nextInboundByteBuffer().writeBytes(additionalBuf); 
     head.fireInboundBufferUpdated(); 
    } 
} 
+0

Можете ли вы уточнить, что «сломал " означает? (И помогает ли это? Http://stackoverflow.com/questions/16469072/migrating-sendupstream-in-netty-4) –

ответ

Смежные вопросы