use of javax.websocket.WebSocketContainer in project jetty.project by eclipse.
the class EndpointEchoTest method testAbstractEchoClassref.
@Test
public void testAbstractEchoClassref() throws Exception {
WebSocketContainer container = ContainerProvider.getWebSocketContainer();
// Issue connect using class reference (class that extends abstract that extends Endpoint)
Session session = container.connectToServer(EchoStringEndpoint.class, serverUri);
if (LOG.isDebugEnabled())
LOG.debug("Client Connected: {}", session);
session.getBasicRemote().sendText("Echo");
if (LOG.isDebugEnabled())
LOG.debug("Client Message Sent");
// TODO: figure out echo verification.
// echoer.messageQueue.awaitMessages(1,1000,TimeUnit.MILLISECONDS);
}
use of javax.websocket.WebSocketContainer in project jetty.project by eclipse.
the class EndpointEchoTest method testBasicEchoInstance.
@Test
public void testBasicEchoInstance() throws Exception {
WebSocketContainer container = ContainerProvider.getWebSocketContainer();
EndpointEchoClient echoer = new EndpointEchoClient();
Assert.assertThat(echoer, instanceOf(javax.websocket.Endpoint.class));
// Issue connect using instance of class that extends Endpoint
Session session = container.connectToServer(echoer, serverUri);
if (LOG.isDebugEnabled())
LOG.debug("Client Connected: {}", session);
session.getBasicRemote().sendText("Echo");
if (LOG.isDebugEnabled())
LOG.debug("Client Message Sent");
echoer.textCapture.messageQueue.awaitMessages(1, 1000, TimeUnit.MILLISECONDS);
}
use of javax.websocket.WebSocketContainer in project javaee7-samples by javaee-samples.
the class MyEndpointTest 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(String endpoint) throws DeploymentException, IOException, URISyntaxException {
WebSocketContainer container = ContainerProvider.getWebSocketContainer();
URI uri = new URI("ws://" + base.getHost() + ":" + base.getPort() + "/" + base.getPath() + "/" + endpoint);
System.out.println("Connecting to: " + uri);
return container.connectToServer(MyEndpointClient.class, uri);
}
use of javax.websocket.WebSocketContainer in project javaee7-samples by javaee-samples.
the class ChatTest 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() + "chat");
return container.connectToServer(endpoint, uri);
}
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-client");
return container.connectToServer(endpoint, uri);
}
Aggregations