Skip to content

Commit

Permalink
Enable compression extension for websockets
Browse files Browse the repository at this point in the history
  • Loading branch information
SquidDev committed May 5, 2018
1 parent f17df15 commit 4c2e97b
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import io.netty.handler.codec.http.websocketx.WebSocketClientHandshaker;
import io.netty.handler.codec.http.websocketx.WebSocketClientHandshakerFactory;
import io.netty.handler.codec.http.websocketx.WebSocketVersion;
import io.netty.handler.codec.http.websocketx.extensions.compression.WebSocketClientCompressionHandler;
import io.netty.handler.ssl.SslContext;
import io.netty.handler.ssl.SslContextBuilder;

Expand All @@ -34,7 +35,7 @@
import java.util.Map;
import java.util.concurrent.Future;

/*
/**
* Provides functionality to verify and connect to a remote websocket.
*/
public final class WebsocketConnector
Expand Down Expand Up @@ -177,7 +178,7 @@ public static Future<?> createConnector( final IAPIEnvironment environment, fina
httpHeaders.add( header.getKey(), header.getValue() );
}

WebSocketClientHandshaker handshaker = WebSocketClientHandshakerFactory.newHandshaker( uri, WebSocketVersion.V13, null, false, httpHeaders );
WebSocketClientHandshaker handshaker = WebSocketClientHandshakerFactory.newHandshaker( uri, WebSocketVersion.V13, null, true, httpHeaders );
final WebsocketConnection connection = new WebsocketConnection( environment, api, handshaker, address );

new Bootstrap()
Expand All @@ -190,7 +191,12 @@ protected void initChannel( SocketChannel ch ) throws Exception
{
ChannelPipeline p = ch.pipeline();
if( ssl != null ) p.addLast( ssl.newHandler( ch.alloc(), uri.getHost(), port ) );
p.addLast( new HttpClientCodec(), new HttpObjectAggregator( 8192 ), connection );
p.addLast(
new HttpClientCodec(),
new HttpObjectAggregator( 8192 ),
WebSocketClientCompressionHandler.INSTANCE,
connection
);
}
} )
.remoteAddress( socketAddress )
Expand Down

0 comments on commit 4c2e97b

Please sign in to comment.