本文整理汇总了Java中io.netty.channel.ChannelProgressivePromise类的典型用法代码示例。如果您正苦于以下问题:Java ChannelProgressivePromise类的具体用法?Java ChannelProgressivePromise怎么用?Java ChannelProgressivePromise使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ChannelProgressivePromise类属于io.netty.channel包,在下文中一共展示了ChannelProgressivePromise类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeRequest
import io.netty.channel.ChannelProgressivePromise; //导入依赖的package包/类
public <T> void writeRequest(NettyResponseFuture<T> future, Channel channel) {
NettyRequest nettyRequest = future.getNettyRequest();
HttpRequest httpRequest = nettyRequest.getHttpRequest();
AsyncHandler<T> handler = future.getAsyncHandler();
// if the channel is dead because it was pooled and the remote
// server decided to close it,
// we just let it go and the channelInactive do its work
if (!Channels.isChannelValid(channel))
return;
try {
if (handler instanceof TransferCompletionHandler)
configureTransferAdapter(handler, httpRequest);
boolean writeBody = !future.isDontWriteBodyBecauseExpectContinue() && httpRequest.getMethod() != HttpMethod.CONNECT && nettyRequest.getBody() != null;
if (!future.isHeadersAlreadyWrittenOnContinue()) {
if (future.getAsyncHandler() instanceof AsyncHandlerExtensions)
AsyncHandlerExtensions.class.cast(future.getAsyncHandler()).onRequestSend(nettyRequest);
ChannelProgressivePromise promise = channel.newProgressivePromise();
ChannelFuture f = writeBody ? channel.write(httpRequest, promise) : channel.writeAndFlush(httpRequest, promise);
f.addListener(new ProgressListener(future.getAsyncHandler(), future, true, 0L));
}
if (writeBody)
nettyRequest.getBody().write(channel, future);
// don't bother scheduling read timeout if channel became invalid
if (Channels.isChannelValid(channel))
scheduleReadTimeout(future);
} catch (Exception e) {
LOGGER.error("Can't write request", e);
abort(channel, future, e);
}
}
示例2: success
import io.netty.channel.ChannelProgressivePromise; //导入依赖的package包/类
void success() {
if (promise.isDone()) {
// No need to notify the progress or fulfill the promise because it's done already.
return;
}
if (promise instanceof ChannelProgressivePromise) {
// Now we know what the total is.
((ChannelProgressivePromise) promise).tryProgress(progress, progress);
}
promise.trySuccess();
}
示例3: success
import io.netty.channel.ChannelProgressivePromise; //导入依赖的package包/类
void success() {
if (promise instanceof ChannelProgressivePromise) {
// Now we know what the total is.
((ChannelProgressivePromise) promise).tryProgress(progress, progress);
}
promise.setSuccess();
}
示例4: newProgressivePromise
import io.netty.channel.ChannelProgressivePromise; //导入依赖的package包/类
@Override
public ChannelProgressivePromise newProgressivePromise() {
return null;
}
示例5: newProgressivePromise
import io.netty.channel.ChannelProgressivePromise; //导入依赖的package包/类
@Override
public ChannelProgressivePromise newProgressivePromise() {
// TODO Auto-generated method stub
return null;
}
示例6: newProgressivePromise
import io.netty.channel.ChannelProgressivePromise; //导入依赖的package包/类
@Override
public ChannelProgressivePromise newProgressivePromise() {
return ctx.newProgressivePromise();
}
示例7: progress
import io.netty.channel.ChannelProgressivePromise; //导入依赖的package包/类
void progress(int amount) {
progress += amount;
if (promise instanceof ChannelProgressivePromise) {
((ChannelProgressivePromise) promise).tryProgress(progress, -1);
}
}
示例8: newProgressivePromise
import io.netty.channel.ChannelProgressivePromise; //导入依赖的package包/类
@Override
public ChannelProgressivePromise newProgressivePromise() {
return null;
}
示例9: newProgressivePromise
import io.netty.channel.ChannelProgressivePromise; //导入依赖的package包/类
@Override
public ChannelProgressivePromise newProgressivePromise() {
return new DefaultChannelProgressivePromise(channel);
}