org.eclipse.jetty.websocket.WebSocketServlet Java Examples

The following examples show how to use org.eclipse.jetty.websocket.WebSocketServlet. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StramTestSupport.java    From attic-apex-core with Apache License 2.0 5 votes vote down vote up
public void start() throws Exception
{
  server = new Server();
  Connector connector = new SelectChannelConnector();
  connector.setPort(port);
  server.addConnector(connector);

    // Setup the basic application "context" for this application at "/"
  // This is also known as the handler tree (in jetty speak)
  ServletContextHandler contextHandler = new ServletContextHandler(ServletContextHandler.SESSIONS);
  contextHandler.setContextPath("/");
  server.setHandler(contextHandler);
  WebSocketServlet webSocketServlet = new WebSocketServlet()
  {
    @Override
    public WebSocket doWebSocketConnect(HttpServletRequest request, String protocol)
    {
      return websocket;
    }
  };

  contextHandler.addServlet(new ServletHolder(webSocketServlet), "/pubsub");
  server.start();
  if (port == 0) {
    port = server.getConnectors()[0].getLocalPort();
  }
}