Java Code Examples for io.netty.handler.codec.http.websocketx.WebSocketVersion#V13

The following examples show how to use io.netty.handler.codec.http.websocketx.WebSocketVersion#V13 . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LBAwareSigV4WebSocketChannelizer.java    From amazon-neptune-tools with Apache License 2.0 5 votes vote down vote up
/**
 * Creates an instance of {@link WebSocketClientHandler} with {@link AwsSigV4ClientHandshaker} as the handshaker
 * for SigV4 auth.
 * @return the instance of clientHandler.
 */
private WebSocketClientHandler createHandler() {
    HandshakeRequestConfig handshakeRequestConfig =
            HandshakeRequestConfig.parse(cluster.authProperties().get(AuthProperties.Property.JAAS_ENTRY));
    WebSocketClientHandshaker handshaker = new LBAwareAwsSigV4ClientHandshaker(
            connection.getUri(),
            WebSocketVersion.V13,
            null,
            false,
            EmptyHttpHeaders.INSTANCE,
            cluster.getMaxContentLength(),
            new ChainedSigV4PropertiesProvider(),
            handshakeRequestConfig);
    return new WebSocketClientHandler(handshaker);
}
 
Example 2
Source File: Utils.java    From haven-platform with Apache License 2.0 5 votes vote down vote up
static WebSocketVersion getWsVersion(String str) {
    switch (str) {
        case "0":
            return WebSocketVersion.V00;
        case "7":
            return WebSocketVersion.V07;
        case "8":
            return WebSocketVersion.V08;
        case "13":
            return WebSocketVersion.V13;
    }
    return WebSocketVersion.UNKNOWN;
}
 
Example 3
Source File: WebsocketChannelInitializer.java    From SynchronizeFX with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void addToPipeline(final ChannelPipeline pipeline) {
    pipeline.addLast("http-codec", new HttpClientCodec());
    pipeline.addLast("aggregator", new HttpObjectAggregator(8192));

    final WebSocketClientHandshaker handShaker = new WhiteSpaceInPathWebSocketClientHandshaker13(serverUri,
            WebSocketVersion.V13, PROTOCOL, false, createHttpHeaders(httpHeaders), Integer.MAX_VALUE);
    pipeline.addLast("websocket-protocol-handler", new WebSocketClientProtocolHandler(handShaker));

    pipeline.addLast("websocket-frame-codec", new ByteBufToWebSocketFrameCodec());
}
 
Example 4
Source File: WebsocketConnectionBuilder.java    From quarkus-http with Apache License 2.0 4 votes vote down vote up
public <R> CompletableFuture<R> connect(Function<Channel, R> connectFunction) {
    io.netty.bootstrap.Bootstrap b = new io.netty.bootstrap.Bootstrap();
    int actualPort = uri.getPort() == -1 ? (uri.getScheme().equals("wss") ? 443 : 80) : uri.getPort();

    final WebSocketClientHandler handler =
            new WebSocketClientHandler(
                    new WebSocketClientHandshaker13(
                            uri, WebSocketVersion.V13, null, false, HttpHeaders.EMPTY_HEADERS, 1280000) {

                        @Override
                        protected FullHttpRequest newHandshakeRequest() {
                            FullHttpRequest request = super.newHandshakeRequest();
                            if (clientNegotiation.getSupportedSubProtocols() != null) {
                                StringBuilder sb = new StringBuilder();
                                for (int i = 0; i < clientNegotiation.getSupportedSubProtocols().size(); ++i) {
                                    if (i > 0) {
                                        sb.append(", ");
                                    }
                                    sb.append(clientNegotiation.getSupportedSubProtocols().get(i));
                                }
                                request.headers().add(HttpHeaderNames.SEC_WEBSOCKET_PROTOCOL, sb.toString());
                            }
                            clientNegotiation.beforeRequest(request.headers());
                            return request;
                        }

                        @Override
                        protected void verify(FullHttpResponse response) {
                            super.verify(response);
                            clientNegotiation.afterRequest(response.headers());
                        }
                    }, connectFunction);

    b.group(eventLoopGroup)
            .channel(NioSocketChannel.class)
            .handler(new ChannelInitializer<SocketChannel>() {
                @Override
                public void initChannel(SocketChannel ch) throws Exception {
                    ChannelPipeline pipeline = ch.pipeline();
                    if (ssl != null) {
                        SSLEngine sslEngine = ssl.createSSLEngine(uri.getHost(), actualPort);
                        sslEngine.setUseClientMode(true);
                        pipeline.addLast("ssl", new SslHandler(sslEngine));
                    }
                    pipeline.addLast("http-codec", new HttpClientCodec());
                    pipeline.addLast("aggregator", new HttpObjectAggregator(65536));
                    pipeline.addLast("ws-handler", handler);
                }
            });

    //System.out.println("WebSocket Client connecting");
    b.connect(uri.getHost(), actualPort).addListener(new ChannelFutureListener() {
        @Override
        public void operationComplete(ChannelFuture future) throws Exception {
            if (future.cause() != null) {
                handler.handshakeFuture.completeExceptionally(future.cause());
            }
        }
    });


    return handler.handshakeFuture;
}
 
Example 5
Source File: Client.java    From arcusplatform with Apache License 2.0 4 votes vote down vote up
public WebsocketClientHandshaker(URI webSocketURL, HttpHeaders customHeaders, int maxFramePayloadLength) {
   super(webSocketURL, WebSocketVersion.V13, null, false, customHeaders, maxFramePayloadLength);
}