Search in sources :

Example 1 with WebSocketInterceptor

use of com.predic8.membrane.core.interceptor.tunnel.WebSocketInterceptor in project service-proxy by membrane.

the class MyApplication method main.

public static void main(String[] args) throws Exception {
    System.out.println("Starting up");
    // create a new service proxy that listens on port 8080 and has a target to localhost:2001
    ServiceProxy sp = createServiceProxy();
    // create an enclosing WebSocket interceptor to add our own Logging interceptor to it
    WebSocketInterceptor ws = new WebSocketInterceptor();
    ws.getInterceptors().add(new MyWebSocketLogInterceptor());
    // attach the WebSocket interceptor to the service proxy
    sp.getInterceptors().add(ws);
    // add the service proxy to a new router instance and start it
    HttpRouter router = new HttpRouter();
    router.add(sp);
    router.init();
    System.out.println("Starting finished - Waiting for WebSocket communication");
}
Also used : ServiceProxy(com.predic8.membrane.core.rules.ServiceProxy) WebSocketInterceptor(com.predic8.membrane.core.interceptor.tunnel.WebSocketInterceptor) MyWebSocketLogInterceptor(com.predic8.membrane.core.interceptor.websocket.custom.MyWebSocketLogInterceptor) HttpRouter(com.predic8.membrane.core.HttpRouter)

Aggregations

HttpRouter (com.predic8.membrane.core.HttpRouter)1 WebSocketInterceptor (com.predic8.membrane.core.interceptor.tunnel.WebSocketInterceptor)1 MyWebSocketLogInterceptor (com.predic8.membrane.core.interceptor.websocket.custom.MyWebSocketLogInterceptor)1 ServiceProxy (com.predic8.membrane.core.rules.ServiceProxy)1