use of javax.websocket.WebSocketContainer in project javaee7-samples by javaee-samples.
the class EncoderEndpointTest method connectToServer.
/**
* Method used to supply connection to the server by passing the naming of
* the websocket endpoint
*
* @param endpoint
* @return
* @throws DeploymentException
* @throws IOException
* @throws URISyntaxException
*/
public Session connectToServer(Class<?> endpoint) throws DeploymentException, IOException, URISyntaxException {
WebSocketContainer container = ContainerProvider.getWebSocketContainer();
URI uri = new URI("ws://" + base.getHost() + ":" + base.getPort() + base.getPath() + "encoder");
return container.connectToServer(endpoint, uri);
}
use of javax.websocket.WebSocketContainer in project javaee7-samples by javaee-samples.
the class MyEndpointTest method connectToServer.
public Session connectToServer(Class<?> endpoint) throws DeploymentException, IOException, URISyntaxException {
WebSocketContainer container = ContainerProvider.getWebSocketContainer();
URI uri = new URI("ws://" + base.getHost() + ":" + base.getPort() + base.getPath() + "websocket");
System.out.println("Connecting to: " + uri);
return container.connectToServer(endpoint, uri);
}
use of javax.websocket.WebSocketContainer in project javaee7-samples by javaee-samples.
the class MyEndpointTest method connectToServer.
public Session connectToServer(Class<?> endpoint, String uriPart) throws DeploymentException, IOException, URISyntaxException {
WebSocketContainer container = ContainerProvider.getWebSocketContainer();
URI uri = new URI("ws://" + base.getHost() + ":" + base.getPort() + base.getPath() + uriPart);
System.out.println("Connecting to: " + uri);
return container.connectToServer(endpoint, uri);
}
use of javax.websocket.WebSocketContainer in project wildfly by wildfly.
the class WebSocketTestCase method assertWebSocket.
private void assertWebSocket(URL webapp) throws InterruptedException, IOException, DeploymentException, URISyntaxException {
AnnotatedClient endpoint = new AnnotatedClient();
WebSocketContainer serverContainer = ContainerProvider.getWebSocketContainer();
try (Session session = serverContainer.connectToServer(endpoint, new URI("ws", "", TestSuiteEnvironment.getServerAddress(), TestSuiteEnvironment.getHttpPort(), webapp.getPath() + "websocket/Stuart", "", ""))) {
Assert.assertEquals("Hello Stuart", endpoint.getMessage());
}
}
use of javax.websocket.WebSocketContainer in project undertow by undertow-io.
the class UndertowContainerProvider method getContainer.
@Override
protected WebSocketContainer getContainer() {
ClassLoader tccl;
if (System.getSecurityManager() == null) {
tccl = Thread.currentThread().getContextClassLoader();
} else {
tccl = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
@Override
public ClassLoader run() {
return Thread.currentThread().getContextClassLoader();
}
});
}
WebSocketContainer webSocketContainer = webSocketContainers.get(tccl);
if (webSocketContainer == null) {
return getDefaultContainer();
}
return webSocketContainer;
}
Aggregations