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();
}
}
你能否澄清“分手“是指? (这有帮助吗?http://stackoverflow.com/questions/16469072/migrating-sendupstream-in-netty-4) –