/** * Create a {@link ConnectionBuilder} for the given URI. * <p>The default implementation creates a builder with the configured * {@link #getXnioWorker() XnioWorker} and {@link #getByteBufferPool() ByteBufferPool} and * then passes it to the {@link #getConnectionBuilderConsumer() consumer} * provided at construction time. */ protected ConnectionBuilder createConnectionBuilder(URI url) { ConnectionBuilder builder = io.undertow.websockets.client.WebSocketClient .connectionBuilder(getXnioWorker(), getByteBufferPool(), url); this.builderConsumer.accept(builder); return builder; }
@Deprecated public static IoFuture<WebSocketChannel> connect(XnioWorker worker, XnioSsl ssl, final ByteBufferPool bufferPool, final OptionMap optionMap, final URI uri, WebSocketVersion version, WebSocketClientNegotiation clientNegotiation) { return connect(worker, ssl, bufferPool, optionMap, uri, version, clientNegotiation, null); }
@Deprecated public static IoFuture<WebSocketChannel> connect(XnioWorker worker, XnioSsl ssl, final ByteBufferPool bufferPool, final OptionMap optionMap, InetSocketAddress bindAddress, final URI uri, WebSocketVersion version, WebSocketClientNegotiation clientNegotiation, Set<ExtensionHandshake> clientExtensions) { return connectionBuilder(worker, bufferPool, uri) .setSsl(ssl) .setOptionMap(optionMap) .setBindAddress(bindAddress) .setVersion(version) .setClientNegotiation(clientNegotiation) .setClientExtensions(clientExtensions) .connect(); }
@Deprecated public static IoFuture<WebSocketChannel> connect(XnioWorker worker, final ByteBufferPool bufferPool, final OptionMap optionMap, final URI uri, WebSocketVersion version) { return connect(worker, bufferPool, optionMap, uri, version, null); }
/** * Create a {@link ConnectionBuilder} for the given URI. * <p>The default implementation creates a builder with the configured * {@link #getXnioWorker() XnioWorker} and {@link #getPoolBufferSize()} and * then passes it to the {@link #getConnectionBuilderConsumer() consumer} * provided at construction time. */ protected ConnectionBuilder createConnectionBuilder(URI url) { ConnectionBuilder builder = io.undertow.websockets.client.WebSocketClient .connectionBuilder(getXnioWorker(), new DefaultByteBufferPool(false, getPoolBufferSize()), url); this.builderConsumer.accept(builder); return builder; }
@Deprecated public static IoFuture<WebSocketChannel> connect(XnioWorker worker, XnioSsl ssl, final ByteBufferPool bufferPool, final OptionMap optionMap, final URI uri, WebSocketVersion version, WebSocketClientNegotiation clientNegotiation, Set<ExtensionHandshake> clientExtensions) { return connect(worker, ssl, bufferPool, optionMap, null, uri, version, clientNegotiation, clientExtensions); }
@Deprecated public static IoFuture<WebSocketChannel> connect(XnioWorker worker, XnioSsl ssl, final ByteBufferPool bufferPool, final OptionMap optionMap, InetSocketAddress bindAddress, final URI uri, WebSocketVersion version, WebSocketClientNegotiation clientNegotiation, Set<ExtensionHandshake> clientExtensions) { return connectionBuilder(worker, bufferPool, uri) .setSsl(ssl) .setOptionMap(optionMap) .setBindAddress(bindAddress) .setVersion(version) .setClientNegotiation(clientNegotiation) .setClientExtensions(clientExtensions) .connect(); }
@Deprecated public static IoFuture<WebSocketChannel> connect(XnioWorker worker, XnioSsl ssl, final ByteBufferPool bufferPool, final OptionMap optionMap, final URI uri, WebSocketVersion version) { return connect(worker, ssl, bufferPool, optionMap, uri, version, null); }
@Deprecated public static IoFuture<WebSocketChannel> connect(XnioWorker worker, XnioSsl ssl, final ByteBufferPool bufferPool, final OptionMap optionMap, InetSocketAddress bindAddress, final URI uri, WebSocketVersion version, WebSocketClientNegotiation clientNegotiation, Set<ExtensionHandshake> clientExtensions) { return connectionBuilder(worker, bufferPool, uri) .setSsl(ssl) .setOptionMap(optionMap) .setBindAddress(bindAddress) .setVersion(version) .setClientNegotiation(clientNegotiation) .setClientExtensions(clientExtensions) .connect(); }
@Deprecated public static IoFuture<WebSocketChannel> connect(XnioWorker worker, final ByteBufferPool bufferPool, final OptionMap optionMap, final URI uri, WebSocketVersion version, WebSocketClientNegotiation clientNegotiation) { return connect(worker, null, bufferPool, optionMap, uri, version, clientNegotiation); }
@Override public UndertowEndpoint connect(URI uri, XEndpointListener<? super UndertowEndpoint> listener) throws Exception { final int bufferSize = UndertowAtts.BUFFER_SIZE.get(config.attributes); final boolean directBuffers = UndertowAtts.DIRECT_BUFFERS.get(config.attributes); final ByteBufferPool pool = new DefaultByteBufferPool(directBuffers, bufferSize); final ConnectionBuilder builder = WebSocketClient.connectionBuilder(worker, pool, uri); if (uri.getScheme().equals("wss")) { final SSLContext sslContext = config.sslContextProvider.getSSLContext(); final ByteBufferPool sslBufferPool = new DefaultByteBufferPool(directBuffers, 17 * 1024); final XnioSsl ssl = new UndertowXnioSsl(worker.getXnio(), OptionMap.EMPTY, sslBufferPool, sslContext); builder.setSsl(ssl); } final WebSocketChannel channel = builder.connect().get(); return UndertowEndpoint.clientOf(scanner, channel, config, listener); }
@Deprecated public static IoFuture<WebSocketChannel> connect(XnioWorker worker, XnioSsl ssl, final ByteBufferPool bufferPool, final OptionMap optionMap, final URI uri, WebSocketVersion version) { return connect(worker, ssl, bufferPool, optionMap, uri, version, null); }
protected ConnectionBuilder createConnectionBuilder(XnioWorker worker, DefaultByteBufferPool bufferPool, String url) { URI uri = createWebsocketUri(url); ConnectionBuilder connectionBuilder = WebSocketClient.connectionBuilder(worker, bufferPool, uri); addSslContext(connectionBuilder); connectionBuilder.setClientNegotiation(new WebSocketClientNegotiation(createSupportedSubProtocols(), createSupportedExtensions()) { @Override public void beforeRequest(final Map<String, List<String>> headers) { //========================================== // Add custom headers //========================================== addCustomHeaders(headers); //========================================== // Add cookies //========================================== addCustomCookies(headers); //========================================== // Add HTTP authenticatiin headers //========================================== addHttpAuthHeaders(headers); } }); return connectionBuilder; }
@Deprecated public static IoFuture<WebSocketChannel> connect(XnioWorker worker, final ByteBufferPool bufferPool, final OptionMap optionMap, final URI uri, WebSocketVersion version) { return connect(worker, bufferPool, optionMap, uri, version, null); }
@Deprecated public static IoFuture<WebSocketChannel> connect(XnioWorker worker, XnioSsl ssl, final ByteBufferPool bufferPool, final OptionMap optionMap, final URI uri, WebSocketVersion version, WebSocketClientNegotiation clientNegotiation) { return connect(worker, ssl, bufferPool, optionMap, uri, version, clientNegotiation, null); }
@Deprecated public static IoFuture<WebSocketChannel> connect(XnioWorker worker, XnioSsl ssl, final ByteBufferPool bufferPool, final OptionMap optionMap, final URI uri, WebSocketVersion version, WebSocketClientNegotiation clientNegotiation, Set<ExtensionHandshake> clientExtensions) { return connect(worker, ssl, bufferPool, optionMap, null, uri, version, clientNegotiation, clientExtensions); }
@Deprecated public static IoFuture<WebSocketChannel> connect(XnioWorker worker, final ByteBufferPool bufferPool, final OptionMap optionMap, final URI uri, WebSocketVersion version, WebSocketClientNegotiation clientNegotiation) { return connect(worker, null, bufferPool, optionMap, uri, version, clientNegotiation); }
@Deprecated public static IoFuture<WebSocketChannel> connect(XnioWorker worker, final ByteBufferPool bufferPool, final OptionMap optionMap, final URI uri, WebSocketVersion version, WebSocketClientNegotiation clientNegotiation) { return connect(worker, null, bufferPool, optionMap, uri, version, clientNegotiation); }
@Deprecated public static IoFuture<WebSocketChannel> connect(XnioWorker worker, XnioSsl ssl, final ByteBufferPool bufferPool, final OptionMap optionMap, final URI uri, WebSocketVersion version) { return connect(worker, ssl, bufferPool, optionMap, uri, version, null); }
@Deprecated public static IoFuture<WebSocketChannel> connect(XnioWorker worker, final ByteBufferPool bufferPool, final OptionMap optionMap, final URI uri, WebSocketVersion version) { return connect(worker, bufferPool, optionMap, uri, version, null); }