/** * Default constructor that creates an instance of * {@link org.eclipse.jetty.websocket.client.WebSocketClient}. */ public JettyWebSocketClient() { this.client = new org.eclipse.jetty.websocket.client.WebSocketClient(); }
/** * Default constructor that creates and manages an instance of a Jetty * {@link org.eclipse.jetty.websocket.client.WebSocketClient WebSocketClient}. * The instance can be obtained with {@link #getJettyClient()} for further * configuration. * * <p><strong>Note: </strong> When this constructor is used {@link Lifecycle} * methods of this class are delegated to the Jetty {@code WebSocketClient}. */ public JettyWebSocketClient() { this.jettyClient = new org.eclipse.jetty.websocket.client.WebSocketClient(); this.externallyManaged = false; }
private static Supplier<WebSocketClient> createTestClientSupplier() { return () -> { SslContextFactory sslContextFactory = new SslContextFactory( /* trustall= */ true ); /* remove extra filters added by jetty on cipher suites */ sslContextFactory.setExcludeCipherSuites(); return new WebSocketClient( sslContextFactory ); }; } }
@Before public void setUp() throws Exception { startServer(); client = new WebSocketClient(); }
@Override public WebSocketClient build() throws Exception { SslContextFactory sslContextFactory = sslVerificationMode == SslVerificationMode.NONE ? new TrustAllSSLContextFactory() : new SslContextFactory(); sslContextFactory.setNeedClientAuth(true); sslContextFactory.setKeyStore(agentKeystore()); sslContextFactory.setKeyStorePassword(keystorePassword()); sslContextFactory.setKeyManagerPassword(keystorePassword()); if (rootCertFile != null) { sslContextFactory.setTrustStore(agentTruststore()); sslContextFactory.setTrustStorePassword(keystorePassword()); } if (sslVerificationMode == SslVerificationMode.NO_VERIFY_HOST) { sslContextFactory.setEndpointIdentificationAlgorithm(null); } WebSocketClient client = new WebSocketClient(sslContextFactory); client.setMaxIdleTimeout(systemEnvironment.getWebsocketMaxIdleTime()); return client; }
private Code makeWsRequest(final String username, final String password) throws Exception { final WebSocketClient wsClient = new WebSocketClient(); wsClient.start(); try { final ClientUpgradeRequest request = new ClientUpgradeRequest(); if (!username.isEmpty()) { final String authHeader = "Basic " + buildBasicAuthHeader(username, password); request.setHeader(HttpHeaders.AUTHORIZATION, authHeader); } final WebSocketListener listener = new WebSocketListener(); final URI wsUri = REST_APP.getWsListener().resolve("/ws/query"); wsClient.connect(listener, wsUri, request); assertThat("Response received", listener.latch.await(30, TimeUnit.SECONDS), is(true)); final Throwable error = listener.error.get(); return error == null ? Code.OK : extractStatusCode(error); } finally { wsClient.stop(); } }
sslContextFactory = createSslFactory(sslService, false, false); client = new WebSocketClient(sslContextFactory);
public void start() { System.out.println("Starting websocket"); webSocketClient = new WebSocketClient(); try { webSocketClient.start(); } catch (Exception e) { LOGGER.error("", e); } try { URI uri = URI.create("ws://" + address + "/stream"); System.out.println(uri); webSocketImpl = new WebSocketImpl(this); ClientUpgradeRequest request = new ClientUpgradeRequest(); webSocketClient.connect(webSocketImpl, uri, request); webSocketImpl.waitForEndpointId(); running = true; } catch (IOException e) { LOGGER.error("", e); } }
@Override public void run(CommandLine theCommandLine) throws ParseException { String target = theCommandLine.getOptionValue("t"); if (isBlank(target) || (!target.startsWith("ws://") && !target.startsWith("wss://"))) { throw new ParseException("Target (-t) needs to be in the form \"ws://foo\" or \"wss://foo\""); } IdDt subsId = new IdDt(theCommandLine.getOptionValue("i")); WebSocketClient client = new WebSocketClient(); SimpleEchoSocket socket = new SimpleEchoSocket(subsId.getIdPart()); try { client.start(); URI echoUri = new URI(target); ClientUpgradeRequest request = new ClientUpgradeRequest(); ourLog.info("Connecting to : {}", echoUri); client.connect(socket, echoUri, request); while (!myQuit) { Thread.sleep(500L); } ourLog.info("Shutting down websocket client"); } catch (Exception e) { throw new CommandFailureException(e); } finally { try { client.stop(); } catch (Exception e) { ourLog.error("Failure", e); } } }
/** * Default constructor that creates an instance of * {@link org.eclipse.jetty.websocket.client.WebSocketClient}. */ public JettyWebSocketClient() { this.client = new org.eclipse.jetty.websocket.client.WebSocketClient(); }
/** * Default constructor that creates an instance of * {@link org.eclipse.jetty.websocket.client.WebSocketClient}. */ public JettyWebSocketClient() { this.client = new org.eclipse.jetty.websocket.client.WebSocketClient(); }
/** * Default constructor that creates and manages an instance of a Jetty * {@link org.eclipse.jetty.websocket.client.WebSocketClient WebSocketClient}. * The instance can be obtained with {@link #getJettyClient()} for further * configuration. * * <p><strong>Note: </strong> When this constructor is used {@link Lifecycle} * methods of this class are delegated to the Jetty {@code WebSocketClient}. */ public JettyWebSocketClient() { this.jettyClient = new org.eclipse.jetty.websocket.client.WebSocketClient(); this.externallyManaged = false; }
public WSClient(String privateKey) { super(privateKey); client = new WebSocketClient(); }
mWebSocketClient = new WebSocketClient(uri) { ... }
/** * A factory method for {@link WebSocketClient} class * * @return */ protected WebSocketClient createWebSocketClient() { final WebSocketClient client = new WebSocketClient( createSslContextFactory()); // you can manipulate the client by overriding this method. return client; }
/** * Creates a SerialClient * @param host The host of the SCAT server * @param port The port of the SCAT server * @param macAddress The mac address of the device to connect to. This is used to identify * a device between the multiple devices that are served with the same SCAT server */ public SerialClient(String host, int port, String macAddress) { this.alias = "SerialClient-" + macAddress; this.client = new WebSocketClient(); String deviceId = DawgUtil.onlyAlphaNumerics(macAddress); this.wsUrl = "ws://" + host + ":" + port + "/scat/trace/" + deviceId.toUpperCase(); }
public void init() throws Exception { saws = new SimpleActuatorWebSocket(); ws = new WebSocketClient(); ws.start(); } }
@Override public Future<Session> connect(Object websocket, URI uri) { client = new WebSocketClient(); client.getPolicy().setIdleTimeout(TIMEOUT); try { client.start(); } catch (Exception e) { e.printStackTrace(); } try { return client.connect(websocket, uri); } catch (IOException e) { throw new RuntimeException(e); } }
/** * Opens the initial websocket connection with the gateway. */ void connect() { try { wsClient = new WebSocketClient(new SslContextFactory()); wsClient.getPolicy().setMaxBinaryMessageSize(Integer.MAX_VALUE); wsClient.getPolicy().setMaxTextMessageSize(Integer.MAX_VALUE); wsClient.start(); wsClient.connect(this, new URI("wss://" + endpoint), new ClientUpgradeRequest()); } catch (Exception e) { Discord4J.LOGGER.error(LogMarkers.VOICE_WEBSOCKET, "Encountered error while connecting voice websocket: ", e); } }
@Override public Connection connect( HostnamePort address ) throws Exception { URI target = URI.create( "ws://" + address.getHost() + ":" + address.getPort() ); client = new WebSocketClient(); client.start(); session = client.connect( this, target ).get( 30, TimeUnit.SECONDS ); server = session.getRemote(); return this; }