ctx.addApplicationListener(new ApplicationListener(
TesterEchoServer.Config.class.getName(), false));
Tomcat.addServlet(ctx, "default", new DefaultServlet());
ctx.addServletMapping("/", "default");
WebSocketContainer wsContainer =
ContainerProvider.getWebSocketContainer();
if (isServerBuffer) {
if (isTextBuffer) {
ctx.addParameter(
org.apache.tomcat.websocket.server.Constants.
TEXT_BUFFER_SIZE_SERVLET_CONTEXT_INIT_PARAM,
"1024");
} else {
ctx.addParameter(
org.apache.tomcat.websocket.server.Constants.
BINARY_BUFFER_SIZE_SERVLET_CONTEXT_INIT_PARAM,
"1024");
}
} else {
if (isTextBuffer) {
wsContainer.setDefaultMaxTextMessageBufferSize(1024);
} else {
wsContainer.setDefaultMaxBinaryMessageBufferSize(1024);
}
}
tomcat.start();
Session wsSession = wsContainer.connectToServer(
TesterProgrammaticEndpoint.class,
ClientEndpointConfig.Builder.create().build(),
new URI("ws://localhost:" + getPort() +
TesterEchoServer.Config.PATH_BASIC));
BasicHandler<?> handler;