Search in sources :

Example 1 with WebSocketHandler

use of org.eclipse.jetty.websocket.server.WebSocketHandler in project jetty.project by eclipse.

the class BrowserDebugTool method prepare.

public void prepare(int port) {
    server = new Server();
    connector = new ServerConnector(server);
    connector.setPort(port);
    server.addConnector(connector);
    WebSocketHandler wsHandler = new WebSocketHandler() {

        @Override
        public void configure(WebSocketServletFactory factory) {
            LOG.debug("Configuring WebSocketServerFactory ...");
            // Registering Frame Debug
            factory.getExtensionFactory().register("@frame-capture", FrameCaptureExtension.class);
            // Setup the desired Socket to use for all incoming upgrade requests
            factory.setCreator(BrowserDebugTool.this);
            // Set the timeout
            factory.getPolicy().setIdleTimeout(30000);
            // Set top end message size
            factory.getPolicy().setMaxTextMessageSize(15 * 1024 * 1024);
        }
    };
    server.setHandler(wsHandler);
    String resourceBase = "src/test/resources/browser-debug-tool";
    ResourceHandler rHandler = new ResourceHandler();
    rHandler.setDirectoriesListed(true);
    rHandler.setResourceBase(resourceBase);
    wsHandler.setHandler(rHandler);
    LOG.info("{} setup on port {}", this.getClass().getName(), port);
}
Also used : ServerConnector(org.eclipse.jetty.server.ServerConnector) WebSocketServletFactory(org.eclipse.jetty.websocket.servlet.WebSocketServletFactory) Server(org.eclipse.jetty.server.Server) WebSocketHandler(org.eclipse.jetty.websocket.server.WebSocketHandler) ResourceHandler(org.eclipse.jetty.server.handler.ResourceHandler)

Aggregations

Server (org.eclipse.jetty.server.Server)1 ServerConnector (org.eclipse.jetty.server.ServerConnector)1 ResourceHandler (org.eclipse.jetty.server.handler.ResourceHandler)1 WebSocketHandler (org.eclipse.jetty.websocket.server.WebSocketHandler)1 WebSocketServletFactory (org.eclipse.jetty.websocket.servlet.WebSocketServletFactory)1