mirror of
https://github.com/bec-project/bec_atlas.git
synced 2025-07-14 07:01:48 +02:00
fix: use serverSettingsService in redis connector
This commit is contained in:
@ -4,6 +4,7 @@ import { firstValueFrom } from 'rxjs';
|
||||
|
||||
export interface AppConfig {
|
||||
baseUrl?: string;
|
||||
wsUrl?: string;
|
||||
}
|
||||
@Injectable()
|
||||
export class AppConfigService {
|
||||
|
@ -2,6 +2,8 @@ import { Injectable, signal, WritableSignal } from '@angular/core';
|
||||
import { io, Socket } from 'socket.io-client';
|
||||
import { Observable } from 'rxjs';
|
||||
import { MessageEndpoints, EndpointInfo } from './redis_endpoints';
|
||||
import { AppConfigService } from '../app-config.service';
|
||||
import { ServerSettingsService } from '../server-settings.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
@ -11,7 +13,7 @@ export class RedisConnectorService {
|
||||
private signals: Map<string, WritableSignal<any>> = new Map();
|
||||
private signalReferenceCount: Map<string, number> = new Map();
|
||||
|
||||
constructor() {
|
||||
constructor(private serverSettings: ServerSettingsService) {
|
||||
this.connect();
|
||||
}
|
||||
|
||||
@ -19,7 +21,7 @@ export class RedisConnectorService {
|
||||
* Connect to the WebSocket server using socket.io
|
||||
*/
|
||||
private connect(): void {
|
||||
this.socket = io('http://localhost', {
|
||||
this.socket = io(this.serverSettings.getSocketAddress(), {
|
||||
transports: ['websocket'], // Use WebSocket only
|
||||
autoConnect: true, // Automatically connect
|
||||
reconnection: true, // Enable automatic reconnection
|
||||
@ -27,7 +29,7 @@ export class RedisConnectorService {
|
||||
auth: {
|
||||
user: 'john_doe',
|
||||
token: '1234',
|
||||
deployment: '678f5e85434914d3e0e2bb3f',
|
||||
deployment: '678aa8d4875568640bd92176',
|
||||
},
|
||||
});
|
||||
|
||||
|
@ -14,10 +14,6 @@ export class ServerSettingsService {
|
||||
}
|
||||
|
||||
getSocketAddress() {
|
||||
const baseUrl =
|
||||
this.appConfigService.getConfig().baseUrl ?? 'http://localhost/api/v1/';
|
||||
if (!baseUrl.startsWith('http'))
|
||||
throw new Error('BaseURL must use the http or https protocol');
|
||||
return `ws${baseUrl.substring(4)}`;
|
||||
return this.appConfigService.getConfig().wsUrl ?? 'http://localhost/';
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user