org.apache.tomcat.websocket.pojo.PojoEndpointClient Java Examples

The following examples show how to use org.apache.tomcat.websocket.pojo.PojoEndpointClient. 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: TesterWsClientAutobahn.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
private static void executeTestCase(WebSocketContainer wsc, int testCase)
        throws Exception {
    URI uri = new URI("ws://" + HOST + ":" + PORT + "/runCase?case=" +
            testCase + "&agent=" + USER_AGENT);
    TestCaseClient testCaseClient = new TestCaseClient();

    Extension permessageDeflate = new WsExtension("permessage-deflate");
    // Advertise support for client_max_window_bits
    // Client only supports some values so there will be some failures here
    // Note Autobahn returns a 400 response if you provide a value for
    // client_max_window_bits
    permessageDeflate.getParameters().add(
            new WsExtensionParameter("client_max_window_bits", null));
    List<Extension> extensions = new ArrayList<>(1);
    extensions.add(permessageDeflate);

    Endpoint ep = new PojoEndpointClient(testCaseClient, null);
    ClientEndpointConfig.Builder builder = ClientEndpointConfig.Builder.create();
    ClientEndpointConfig config = builder.extensions(extensions).build();

    wsc.connectToServer(ep, config, uri);
    testCaseClient.waitForClose();
}