class WebSocketProxyServerHandler extends AbstractWebSocketHandler implements RoutedServicesUser {

    @Override
    public void afterConnectionEstablished(WebSocketSession webSocketSession) throws Exception {
        String[] uriParts = getUriParts(webSocketSession);
        if (uriParts != null && uriParts.length == 5) {
            String majorVersion = uriParts[2];
            String serviceId = uriParts[3];
            String path = uriParts[4];

            RoutedServices routedServices = routedServicesMap.get(serviceId);

            if (routedServices != null) {
                RoutedService service = routedServices.findServiceByGatewayUrl("ws/" + majorVersion);
                if (service == null) {
                    closeWebSocket(webSocketSession, CloseStatus.NOT_ACCEPTABLE,
                        String.format("Requested ws/%s url is not known by the gateway", majorVersion));
                    return;
                }

                ServiceInstance serviceInstance = findServiceInstance(serviceId);
                if (serviceInstance != null) {
                    openWebSocketConnection(service, serviceInstance, serviceInstance, path, webSocketSession);
                } else {
                    closeWebSocket(webSocketSession, CloseStatus.SERVICE_RESTARTED,
                        String.format("Requested service %s does not have available instance", serviceId));
                }
            } else {
                closeWebSocket(webSocketSession, CloseStatus.NOT_ACCEPTABLE,
                    String.format("Requested service %s is not known by the gateway", serviceId));
            }
        } else {
            closeWebSocket(webSocketSession, CloseStatus.NOT_ACCEPTABLE, "Invalid URL format");
        }
    }

    @Autowired public  WebSocketProxyServerHandler(DiscoveryClient discovery, SslContextFactoryProvider jettySslContextFactoryProvider);
    public  WebSocketProxyServerHandler(DiscoveryClient discovery, SslContextFactoryProvider sslContextFactoryProvider,
                                       Map<String, WebSocketRoutedSession> routedSessions, WebSocketRoutedSessionFactory webSocketRoutedSessionFactory);

}