From 8ef1b92d28bb3bb7afa207dd51df3b90a87dae35 Mon Sep 17 00:00:00 2001 From: Ehsan Rezaei Date: Fri, 6 Dec 2024 12:05:54 +0100 Subject: [PATCH] AAE-20808 Code refactoring --- .../src/lib/services/web-socket.service.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/process-services-cloud/src/lib/services/web-socket.service.ts b/lib/process-services-cloud/src/lib/services/web-socket.service.ts index b1750c0bfe..75fb71a7c2 100644 --- a/lib/process-services-cloud/src/lib/services/web-socket.service.ts +++ b/lib/process-services-cloud/src/lib/services/web-socket.service.ts @@ -16,7 +16,7 @@ */ import { createClient } from 'graphql-ws'; -import { Inject, Injectable, Optional } from '@angular/core'; +import { inject, Inject, Injectable, Optional } from '@angular/core'; import { GraphQLWsLink } from '@apollo/client/link/subscriptions'; import { WebSocketLink } from '@apollo/client/link/ws'; import { @@ -38,10 +38,8 @@ import { onError } from '@apollo/client/link/error'; import { RetryLink } from '@apollo/client/link/retry'; import { getMainDefinition } from '@apollo/client/utilities'; import { switchMap, take, tap } from 'rxjs/operators'; -import { AuthenticationService } from '@alfresco/adf-core'; +import { AppConfigService, AuthenticationService } from '@alfresco/adf-core'; import { FeaturesServiceToken, IFeaturesService } from '@alfresco/adf-core/feature-flags'; -import { BaseCloudService } from './base-cloud.service'; -import { AdfHttpClient } from '@alfresco/adf-core/api'; interface serviceOptions { apolloClientName: string; @@ -53,20 +51,18 @@ interface serviceOptions { @Injectable({ providedIn: 'root' }) -export class WebSocketService extends BaseCloudService { +export class WebSocketService { + private appConfigService = inject(AppConfigService); private subscriptionProtocol: 'graphql-ws' | 'transport-ws' = 'transport-ws'; private wsLink: GraphQLWsLink | WebSocketLink; private httpLinkHandler: HttpLinkHandler; constructor( - adfHttpClient: AdfHttpClient, private readonly apollo: Apollo, private readonly httpLink: HttpLink, private readonly authService: AuthenticationService, @Optional() @Inject(FeaturesServiceToken) private featuresService: IFeaturesService - ) { - super(adfHttpClient); - } + ) {} public getSubscription(options: serviceOptions): Observable> { const { apolloClientName, subscriptionOptions } = options; @@ -91,6 +87,10 @@ export class WebSocketService extends BaseCloudService { ); } + private get contextRoot() { + return this.appConfigService.get('bpmHost', ''); + } + private createWsUrl(serviceUrl: string): string { const url = new URL(serviceUrl, this.contextRoot); const protocol = url.protocol === 'https:' ? 'wss:' : 'ws:';