class ExtensionWebSocketClient {

    protected String validifyUrl(String url) {
        if (url == null) {
            throw new IllegalArgumentException("Must give a valid URL to connect to the websocket");
        }

        boolean usesSSL = true;
        // Ensure prepended by wss:// and not http:// or https://
        if (url.startsWith("http://")) {
            url = url.substring("http://".length());
            usesSSL = false;
        }
        else if (url.startsWith("https://")) {
            url = url.substring("https://".length());
        }
        if (!url.startsWith("ws://") && !url.startsWith("wss://")) {
            String prefix = "wss://";
            if (!usesSSL) {
                prefix = "ws://";
            }
            url = prefix + url;
        }
        
        // Ensure it ends with /api/v{version number}/wsock/websocket
        if (!url.matches(".*/api/v[0-9]+/wsock/websocket")) {
         // Sometimes generic urls end with a '/' already, so we only want to add one if it does not already exist
            if (!url.endsWith("/")) { 
                url = url + "/";
            }
            url = url + "api/v1/wsock/websocket";
        }
        
        return url;
    }

    public  ExtensionWebSocketClient(String sourceName);

}