Search in sources :

Example 1 with EchoHandler

use of org.eclipse.jetty.websocket.jsr356.EchoHandler in project jetty.project by eclipse.

the class MisbehavingClassTest method startServer.

@SuppressWarnings("Duplicates")
@BeforeClass
public static void startServer() throws Exception {
    server = new Server();
    ServerConnector connector = new ServerConnector(server);
    server.addConnector(connector);
    handler = new EchoHandler();
    ContextHandler context = new ContextHandler();
    context.setContextPath("/");
    context.setHandler(handler);
    server.setHandler(context);
    // Start Server
    server.start();
    String host = connector.getHost();
    if (host == null) {
        host = "localhost";
    }
    int port = connector.getLocalPort();
    serverUri = new URI(String.format("ws://%s:%d/", host, port));
}
Also used : ServerConnector(org.eclipse.jetty.server.ServerConnector) ContextHandler(org.eclipse.jetty.server.handler.ContextHandler) Server(org.eclipse.jetty.server.Server) EchoHandler(org.eclipse.jetty.websocket.jsr356.EchoHandler) URI(java.net.URI) BeforeClass(org.junit.BeforeClass)

Example 2 with EchoHandler

use of org.eclipse.jetty.websocket.jsr356.EchoHandler in project jetty.project by eclipse.

the class EndpointEchoTest method startServer.

@BeforeClass
public static void startServer() throws Exception {
    server = new Server();
    ServerConnector connector = new ServerConnector(server);
    server.addConnector(connector);
    handler = new EchoHandler();
    ContextHandler context = new ContextHandler();
    context.setContextPath("/");
    context.setHandler(handler);
    server.setHandler(context);
    // Start Server
    server.start();
    String host = connector.getHost();
    if (host == null) {
        host = "localhost";
    }
    int port = connector.getLocalPort();
    serverUri = new URI(String.format("ws://%s:%d/", host, port));
}
Also used : ServerConnector(org.eclipse.jetty.server.ServerConnector) ContextHandler(org.eclipse.jetty.server.handler.ContextHandler) Server(org.eclipse.jetty.server.Server) URI(java.net.URI) EchoStringEndpoint(org.eclipse.jetty.websocket.jsr356.samples.EchoStringEndpoint) BeforeClass(org.junit.BeforeClass)

Aggregations

URI (java.net.URI)2 Server (org.eclipse.jetty.server.Server)2 ServerConnector (org.eclipse.jetty.server.ServerConnector)2 ContextHandler (org.eclipse.jetty.server.handler.ContextHandler)2 BeforeClass (org.junit.BeforeClass)2 EchoHandler (org.eclipse.jetty.websocket.jsr356.EchoHandler)1 EchoStringEndpoint (org.eclipse.jetty.websocket.jsr356.samples.EchoStringEndpoint)1