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 2bb5ce5 commit 9809e14
Showing 1 changed file with 9 additions and 3 deletions.
Expand Up @@ -22,6 +22,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 @@ -35,7 +36,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 @@ -178,7 +179,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 @@ -191,7 +192,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 9809e14

Please sign in to comment.