use of javax.websocket.WebSocketContainer in project javaee7-samples by javaee-samples.
the class MyClientTest method connectToServer.
public Session connectToServer(Class<?> endpoint) throws DeploymentException, IOException, URISyntaxException {
WebSocketContainer container = ContainerProvider.getWebSocketContainer();
assertNotNull(container);
assertNotNull(base);
URI uri = new URI("ws://" + base.getHost() + ":" + base.getPort() + base.getPath() + "encoder-programmatic");
return container.connectToServer(endpoint, uri);
}
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 javaee7-samples by javaee-samples.
the class Client method main.
public static void main(String[] args) {
try {
WebSocketContainer container = ContainerProvider.getWebSocketContainer();
String uri = "ws://echo.websocket.org:80/";
System.out.println("Connecting to " + uri);
container.connectToServer(MyClientEndpoint.class, URI.create(uri));
messageLatch.await(100, TimeUnit.SECONDS);
} catch (DeploymentException | InterruptedException | IOException ex) {
Logger.getLogger(Client.class.getName()).log(Level.SEVERE, null, ex);
}
}
Aggregations