[#735] Make sure the handshake ChannelFuture is notified after the right encoder is present in the ChannelPipeline

This commit is contained in:
Norman Maurer 2012-11-13 09:26:32 +01:00
parent d177fd5a17
commit efaa5c2ff5
3 changed files with 12 additions and 4 deletions

View File

@ -19,6 +19,7 @@ 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;
@ -172,6 +173,7 @@ public class WebSocketClientHandshaker00 extends WebSocketClientHandshaker {
request.setContent(Unpooled.copiedBuffer(key3));
ChannelFuture handshakeFuture = channel.newFuture();
ChannelFuture future = channel.write(request);
future.addListener(new ChannelFutureListener() {
@ -183,8 +185,9 @@ public class WebSocketClientHandshaker00 extends WebSocketClientHandshaker {
"ws-encoder", new WebSocket00FrameEncoder());
}
});
future.addListener(new ChannelFutureNotifier(handshakeFuture));
return future;
return handshakeFuture;
}
/**

View File

@ -18,6 +18,7 @@ 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;
@ -151,6 +152,7 @@ public class WebSocketClientHandshaker08 extends WebSocketClientHandshaker {
}
}
ChannelFuture handshakeFuture = channel.newFuture();
ChannelFuture future = channel.write(request);
future.addListener(new ChannelFutureListener() {
@ -162,8 +164,9 @@ public class WebSocketClientHandshaker08 extends WebSocketClientHandshaker {
"ws-encoder", new WebSocket08FrameEncoder(true));
}
});
future.addListener(new ChannelFutureNotifier(handshakeFuture));
return future;
return handshakeFuture;
}
/**

View File

@ -18,6 +18,7 @@ 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;
@ -151,6 +152,7 @@ public class WebSocketClientHandshaker13 extends WebSocketClientHandshaker {
}
}
ChannelFuture handshakeFuture = channel.newFuture();
ChannelFuture future = channel.write(request);
future.addListener(new ChannelFutureListener() {
@ -162,8 +164,8 @@ public class WebSocketClientHandshaker13 extends WebSocketClientHandshaker {
"ws-encoder", new WebSocket13FrameEncoder(true));
}
});
return future;
future.addListener(new ChannelFutureNotifier(handshakeFuture));
return handshakeFuture;
}
/**