List of usage examples for javax.websocket ClientEndpointConfig getUserProperties
Map<String, Object> getUserProperties();
From source file:com.almende.eve.transport.ws.WsClientTransport.java
@Override public void connect() throws IOException { if (session != null) { return;//from w ww . j a v a2 s . co m } if (client == null) { client = ClientManager.createClient(); client.setDefaultMaxSessionIdleTimeout(-1); } try { final ClientEndpointConfig cec = ClientEndpointConfig.Builder.create().build(); cec.getUserProperties().put("address", getAddress()); session = client.connectToServer(WebsocketEndpoint.class, cec, URIUtil.parse(serverUrl + "?id=" + myId)); } catch (final DeploymentException e) { LOG.log(Level.WARNING, "Can't connect to server", e); } catch (final URISyntaxException e) { LOG.log(Level.WARNING, "Can't parse server address", e); } }
From source file:com.github.mrstampy.gameboot.otp.websocket.OtpWebSocketTest.java
private void createEncryptedChannel() throws Exception { ClientEndpointConfig config = ClientEndpointConfig.Builder.create().build(); config.getUserProperties().put(WsWebSocketContainer.SSL_CONTEXT_PROPERTY, sslContext); encChannel = ContainerProvider.getWebSocketContainer().connectToServer(endpoint, config, new URI(createEncUriString())); assertTrue(encChannel.isOpen());// w w w.j a va2s . co m }
From source file:com.github.mrstampy.gameboot.otp.websocket.OtpWebSocketTest.java
private void createClearChannel() throws Exception { ClientEndpointConfig config = ClientEndpointConfig.Builder.create().build(); config.getUserProperties().put(WsWebSocketContainer.SSL_CONTEXT_PROPERTY, sslContext); clearChannel = ContainerProvider.getWebSocketContainer().connectToServer(endpoint, config, new URI(createClearUriString())); assertTrue(clearChannel.isOpen());/*from ww w. j av a2 s . co m*/ CountDownLatch cdl = new CountDownLatch(1); endpoint.setResponseLatch(cdl); cdl.await(1, TimeUnit.SECONDS); assertNotNull(endpoint.getSystemId()); assertEquals(clearChannel, endpoint.getSession()); }