2
如何从客户端得到数据immediantly在服务器网状4.如何从客户端直接读取数据?
在那一刻,我将数据发送到客户端,客户端送我data.But处理程序(方法channelRead()
)收到后才服务器sended数据数据
我将在进程列表中的问题,我用网状4:
- 从客户
- 开始计算响应
- 获取数据的一些业务数据发送到客户端为(
ctx.writeAndFlush()
)(OK) - 继续从客户端计算响应
- 应该得到的数据(这里有一个问题)
- 发送计算响应客户端(发送OK)。
我的代码: 处理器
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
logger.debug("Start read handler " + ctx.channel().toString());
ByteBuf b = (ByteBuf) msg;
ctx.write(Unpooled.copiedBuffer(new Test.send(ctx,b));
}
测试
public class Test
public byte[] send(ChannelHandlerContext ctx,ByteBuf b){
// start calculates
ctx.writeAndFlush(Unpooled.copiedBuffer(some data)); - its ok
// calculates .. (during here i should get data from client but nothing happens. Why does the channel blocks receiving data ?)
return response;
}