Also move the replacement of the decoder to the ChannelFutureListener for the websocket upgrade. See #586

This commit is contained in:
Norman Maurer 2012-09-09 08:21:32 +02:00
parent fb17af4263
commit c6436ad470
3 changed files with 9 additions and 7 deletions

View File

@ -172,18 +172,18 @@ public class WebSocketServerHandshaker00 extends WebSocketServerHandshaker {
} }
// Upgrade the connection and send the handshake response. // Upgrade the connection and send the handshake response.
ChannelPipeline p = channel.pipeline(); ChannelFuture future = channel.write(res);
future.addListener(new ChannelFutureListener() {
@Override
public void operationComplete(ChannelFuture future) {
ChannelPipeline p = future.channel().pipeline();
if (p.get(HttpChunkAggregator.class) != null) { if (p.get(HttpChunkAggregator.class) != null) {
p.remove(HttpChunkAggregator.class); p.remove(HttpChunkAggregator.class);
} }
p.replace(HttpRequestDecoder.class, "wsdecoder", p.replace(HttpRequestDecoder.class, "wsdecoder",
new WebSocket00FrameDecoder(getMaxFramePayloadLength())); new WebSocket00FrameDecoder(getMaxFramePayloadLength()));
ChannelFuture future = channel.write(res);
future.addListener(new ChannelFutureListener() {
public void operationComplete(ChannelFuture future) {
ChannelPipeline p = future.channel().pipeline();
p.replace(HttpResponseEncoder.class, "wsencoder", new WebSocket00FrameEncoder()); p.replace(HttpResponseEncoder.class, "wsencoder", new WebSocket00FrameEncoder());
} }
}); });

View File

@ -148,6 +148,7 @@ public class WebSocketServerHandshaker08 extends WebSocketServerHandshaker {
// Upgrade the connection and send the handshake response. // Upgrade the connection and send the handshake response.
future.addListener(new ChannelFutureListener() { future.addListener(new ChannelFutureListener() {
@Override
public void operationComplete(ChannelFuture future) { public void operationComplete(ChannelFuture future) {
ChannelPipeline p = future.channel().pipeline(); ChannelPipeline p = future.channel().pipeline();
if (p.get(HttpChunkAggregator.class) != null) { if (p.get(HttpChunkAggregator.class) != null) {

View File

@ -148,6 +148,7 @@ public class WebSocketServerHandshaker13 extends WebSocketServerHandshaker {
// Upgrade the connection and send the handshake response. // Upgrade the connection and send the handshake response.
future.addListener(new ChannelFutureListener() { future.addListener(new ChannelFutureListener() {
@Override
public void operationComplete(ChannelFuture future) { public void operationComplete(ChannelFuture future) {
ChannelPipeline p = future.channel().pipeline(); ChannelPipeline p = future.channel().pipeline();
if (p.get(HttpChunkAggregator.class) != null) { if (p.get(HttpChunkAggregator.class) != null) {