use of org.eclipse.jetty.websocket.servlet.WebSocketServletFactory 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);
}
use of org.eclipse.jetty.websocket.servlet.WebSocketServletFactory in project buck by facebook.
the class StreamingWebSocketServlet method configure.
@Override
public void configure(WebSocketServletFactory factory) {
// Most implementations of this method simply invoke factory.register(DispatchSocket.class);
// however, that requires DispatchSocket to have a no-arg constructor. That does not work for
// us because we would like all WebSockets created by this factory to have a reference to this
// parent class. This is why we override the default WebSocketCreator for the factory.
WebSocketCreator wrapperCreator = (req, resp) -> new MyWebSocket();
factory.setCreator(wrapperCreator);
}
use of org.eclipse.jetty.websocket.servlet.WebSocketServletFactory in project jetty.project by eclipse.
the class AnnotatedMaxMessageSizeTest method startServer.
@BeforeClass
public static void startServer() throws Exception {
server = new Server();
connector = new ServerConnector(server);
server.addConnector(connector);
WebSocketHandler wsHandler = new WebSocketHandler() {
@Override
public void configure(WebSocketServletFactory factory) {
factory.register(BigEchoSocket.class);
}
};
server.setHandler(wsHandler);
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));
}
use of org.eclipse.jetty.websocket.servlet.WebSocketServletFactory in project jetty.project by eclipse.
the class BatchModeTest method prepare.
@Before
public void prepare() throws Exception {
server = new Server();
connector = new ServerConnector(server);
server.addConnector(connector);
WebSocketHandler handler = new WebSocketHandler() {
@Override
public void configure(WebSocketServletFactory factory) {
factory.register(EchoSocket.class);
}
};
server.setHandler(handler);
client = new WebSocketClient();
server.addBean(client, true);
server.start();
}
use of org.eclipse.jetty.websocket.servlet.WebSocketServletFactory in project camel by apache.
the class WebsocketEndpointConfigurationTest method testSetServletNoMinThreadsNoMaxThreadsNoThreadPool.
@Test
public void testSetServletNoMinThreadsNoMaxThreadsNoThreadPool() throws Exception {
port = AvailablePortFinder.getNextAvailable(16331);
String uri = "websocket://localhost:" + port + "/bar?bufferSize=25000&maxIdleTime=3000";
WebsocketEndpoint websocketEndpoint = (WebsocketEndpoint) context.getEndpoint(uri);
WebsocketComponent component = websocketEndpoint.getComponent();
Consumer consumer = websocketEndpoint.createConsumer(processor);
component.connect((WebsocketProducerConsumer) consumer);
assertNotNull(consumer);
assertEquals(WebsocketConsumer.class, consumer.getClass());
// just check the servlet initial parameters
ConnectorRef conector = WebsocketComponent.getConnectors().values().iterator().next();
ServletContextHandler context = (ServletContextHandler) conector.server.getHandler();
String buffersize = context.getInitParameter("bufferSize");
assertEquals("Got a wrong buffersize", "25000", buffersize);
String maxIdleTime = context.getInitParameter("maxIdleTime");
assertEquals("Got a wrong maxIdleTime", "3000", maxIdleTime);
WebSocketServletFactory factory = (WebSocketServletFactory) context.getServletContext().getAttribute(WebSocketServletFactory.class.getName());
int factoryBufferSize = factory.getPolicy().getInputBufferSize();
assertEquals("Got a wrong buffersize", 25000, factoryBufferSize);
long factoryMaxIdleTime = factory.getPolicy().getIdleTimeout();
assertEquals("Got a wrong maxIdleTime", 3000, factoryMaxIdleTime);
}
Aggregations