[#735] Improve the notification of the handshake future
This commit is contained in:
parent
efaa5c2ff5
commit
3b729848dc
@ -19,7 +19,6 @@ import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.ChannelFutureListener;
|
||||
import io.netty.channel.ChannelFutureNotifier;
|
||||
import io.netty.channel.ChannelPipeline;
|
||||
import io.netty.handler.codec.http.DefaultHttpRequest;
|
||||
import io.netty.handler.codec.http.HttpHeaders.Names;
|
||||
@ -173,7 +172,7 @@ public class WebSocketClientHandshaker00 extends WebSocketClientHandshaker {
|
||||
|
||||
request.setContent(Unpooled.copiedBuffer(key3));
|
||||
|
||||
ChannelFuture handshakeFuture = channel.newFuture();
|
||||
final ChannelFuture handshakeFuture = channel.newFuture();
|
||||
ChannelFuture future = channel.write(request);
|
||||
|
||||
future.addListener(new ChannelFutureListener() {
|
||||
@ -183,9 +182,14 @@ public class WebSocketClientHandshaker00 extends WebSocketClientHandshaker {
|
||||
p.addAfter(
|
||||
p.context(HttpRequestEncoder.class).name(),
|
||||
"ws-encoder", new WebSocket00FrameEncoder());
|
||||
|
||||
if (future.isSuccess()) {
|
||||
handshakeFuture.setSuccess();
|
||||
} else {
|
||||
handshakeFuture.setFailure(future.cause());
|
||||
}
|
||||
}
|
||||
});
|
||||
future.addListener(new ChannelFutureNotifier(handshakeFuture));
|
||||
|
||||
return handshakeFuture;
|
||||
}
|
||||
|
@ -18,7 +18,6 @@ package io.netty.handler.codec.http.websocketx;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.ChannelFutureListener;
|
||||
import io.netty.channel.ChannelFutureNotifier;
|
||||
import io.netty.channel.ChannelPipeline;
|
||||
import io.netty.handler.codec.http.DefaultHttpRequest;
|
||||
import io.netty.handler.codec.http.HttpHeaders.Names;
|
||||
@ -152,7 +151,7 @@ public class WebSocketClientHandshaker08 extends WebSocketClientHandshaker {
|
||||
}
|
||||
}
|
||||
|
||||
ChannelFuture handshakeFuture = channel.newFuture();
|
||||
final ChannelFuture handshakeFuture = channel.newFuture();
|
||||
ChannelFuture future = channel.write(request);
|
||||
|
||||
future.addListener(new ChannelFutureListener() {
|
||||
@ -162,9 +161,14 @@ public class WebSocketClientHandshaker08 extends WebSocketClientHandshaker {
|
||||
p.addAfter(
|
||||
p.context(HttpRequestEncoder.class).name(),
|
||||
"ws-encoder", new WebSocket08FrameEncoder(true));
|
||||
|
||||
if (future.isSuccess()) {
|
||||
handshakeFuture.setSuccess();
|
||||
} else {
|
||||
handshakeFuture.setFailure(future.cause());
|
||||
}
|
||||
}
|
||||
});
|
||||
future.addListener(new ChannelFutureNotifier(handshakeFuture));
|
||||
|
||||
return handshakeFuture;
|
||||
}
|
||||
|
@ -18,7 +18,6 @@ package io.netty.handler.codec.http.websocketx;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.ChannelFutureListener;
|
||||
import io.netty.channel.ChannelFutureNotifier;
|
||||
import io.netty.channel.ChannelPipeline;
|
||||
import io.netty.handler.codec.http.DefaultHttpRequest;
|
||||
import io.netty.handler.codec.http.HttpHeaders.Names;
|
||||
@ -152,7 +151,7 @@ public class WebSocketClientHandshaker13 extends WebSocketClientHandshaker {
|
||||
}
|
||||
}
|
||||
|
||||
ChannelFuture handshakeFuture = channel.newFuture();
|
||||
final ChannelFuture handshakeFuture = channel.newFuture();
|
||||
ChannelFuture future = channel.write(request);
|
||||
|
||||
future.addListener(new ChannelFutureListener() {
|
||||
@ -162,9 +161,14 @@ public class WebSocketClientHandshaker13 extends WebSocketClientHandshaker {
|
||||
p.addAfter(
|
||||
p.context(HttpRequestEncoder.class).name(),
|
||||
"ws-encoder", new WebSocket13FrameEncoder(true));
|
||||
|
||||
if (future.isSuccess()) {
|
||||
handshakeFuture.setSuccess();
|
||||
} else {
|
||||
handshakeFuture.setFailure(future.cause());
|
||||
}
|
||||
}
|
||||
});
|
||||
future.addListener(new ChannelFutureNotifier(handshakeFuture));
|
||||
return handshakeFuture;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user