use of io.undertow.websockets.jsr.ServerEndpointConfigImpl in project undertow by undertow-io.
the class ProgramaticAutobahnServer method run.
public void run() {
Xnio xnio = Xnio.getInstance();
try {
XnioWorker worker = xnio.createWorker(OptionMap.builder().set(Options.CONNECTION_HIGH_WATER, 1000000).set(Options.CONNECTION_LOW_WATER, 1000000).set(Options.WORKER_TASK_CORE_THREADS, 10).set(Options.WORKER_TASK_MAX_THREADS, 12).set(Options.TCP_NODELAY, true).set(Options.CORK, true).getMap());
OptionMap serverOptions = OptionMap.builder().set(Options.TCP_NODELAY, true).set(Options.REUSE_ADDRESSES, true).getMap();
DefaultByteBufferPool pool = new DefaultByteBufferPool(true, 8192);
HttpOpenListener openListener = new HttpOpenListener(pool);
ChannelListener acceptListener = ChannelListeners.openListenerAdapter(openListener);
AcceptingChannel<StreamConnection> server = worker.createStreamConnectionServer(new InetSocketAddress(port), acceptListener, serverOptions);
server.resumeAccepts();
final ServletContainer container = ServletContainer.Factory.newInstance();
DeploymentInfo builder = new DeploymentInfo().setClassLoader(ProgramaticAutobahnServer.class.getClassLoader()).setContextPath("/").setClassIntrospecter(TestClassIntrospector.INSTANCE).setDeploymentName("servletContext.war").addFilter(new FilterInfo("filter", JsrWebSocketFilter.class)).addFilterUrlMapping("filter", "/*", DispatcherType.REQUEST).addServletContextAttribute(WebSocketDeploymentInfo.ATTRIBUTE_NAME, new WebSocketDeploymentInfo().setBuffers(pool).setWorker(worker).setDispatchToWorkerThread(true).addEndpoint(new ServerEndpointConfigImpl(ProgramaticAutobahnEndpoint.class, "/")).addExtension(new PerMessageDeflateHandshake()));
DeploymentManager manager = container.addDeployment(builder);
manager.deploy();
openListener.setRootHandler(manager.start());
} catch (Exception e) {
throw new RuntimeException(e);
}
}
Aggregations