0

请解释一下,ChannelProgressiveFutureListener iterface的operationProgressed方法中的progress和total变量代表什么,是不是代表total no bytes transfer,下面是代码及其输出结果:

 ChannelFuture future = channel.writeAndFlush(bodyRequestEncoder, channel.newProgressivePromise());
            future.addListener(new ChannelProgressiveFutureListener() {

                @Override
                public void operationComplete(ChannelProgressiveFuture future) throws Exception {
                    // TODO Auto-generated method stub

                }

                @Override
                public void operationProgressed(ChannelProgressiveFuture future, long progress, long total) throws Exception {
                    System.out.println("progress : " + progress + " of total: " + total);

                }
            });

和控制台输出:

progress : 1 of total: -1
progress : 2 of total: -1
progress : 3 of total: -1
progress : 4 of total: -1
progress : 5 of total: -1
progress : 6 of total: -1
progress : 7 of total: -1
4

1 回答 1

0

progress是以百分比表示的进度,是total“当进度到达时表示操作结束的数字。如果操作结束未知,则为 -1”。

查看Netty API 文档

于 2013-07-31T14:57:49.620 回答