class ExtensionWebSocketClient {

    synchronized public CompletableFuture<Boolean> connectToSource() {
        // Only create the authFuture if there has been no request or a failed request, and a websocket request has 
        // been made
        if (authFuture != null && (sourceFuture == null || !sourceFuture.getNow(true))) {
            // Builds a Future that sends a connection message and waits for the result if authentication succeeded,
            // or is immediately false if authentication (or by extension the websocket connection) failed
            sourceFuture = authFuture.thenComposeAsync(
                    (authSuccess) ->
                        {
                            if (authSuccess) {
                                doConnectionToSource();
                                return new CompletableFuture<Boolean>();
                            } else {
                                return CompletableFuture.completedFuture(false);
                            }
                        }
                    );
        }
        return sourceFuture;
    }

    public  ExtensionWebSocketClient(String sourceName);

}