From 09279f6d9963433f27194c8e5984825e4e9de094 Mon Sep 17 00:00:00 2001 From: Steven Guiheux Date: Wed, 26 Jun 2019 15:10:26 +0200 Subject: [PATCH] wip --- ui/Caddyfile | 2 +- ui/src/app/app.component.ts | 23 ++++++----------------- 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/ui/Caddyfile b/ui/Caddyfile index f5a9ae9ab2..809bf10106 100644 --- a/ui/Caddyfile +++ b/ui/Caddyfile @@ -26,4 +26,4 @@ header_upstream Authorization {>Authorization} header_upstream Session-Token {>Session-Token} } -} \ No newline at end of file +} diff --git a/ui/src/app/app.component.ts b/ui/src/app/app.component.ts index 06fdc6a6dc..887e039714 100644 --- a/ui/src/app/app.component.ts +++ b/ui/src/app/app.component.ts @@ -8,6 +8,7 @@ import { TranslateService } from '@ngx-translate/core'; import { Observable } from 'rxjs'; import { bufferTime, filter, map, mergeMap } from 'rxjs/operators'; import { Subscription } from 'rxjs/Subscription'; +import { WebSocketSubject } from 'rxjs/webSocket'; import * as format from 'string-format-obj'; import { environment } from '../environments/environment'; import { AppService } from './app.service'; @@ -21,7 +22,6 @@ import { ToastService } from './shared/toast/ToastService'; import { CDSSharedWorker } from './shared/worker/shared.worker'; import { CDSWebWorker } from './shared/worker/web.worker'; import { CDSWorker } from './shared/worker/worker'; -import { WebSocketSubject } from 'rxjs/webSocket'; @Component({ selector: 'app-root', @@ -98,7 +98,7 @@ export class AppComponent implements OnInit { } else { this.isConnected = true; this.startSSE(); - this.startWebSocket2(); + this.startWebSocket(); } this.startVersionWorker(); }); @@ -150,26 +150,15 @@ export class AppComponent implements OnInit { } } - startWebSocket2(): void { - let exampleSocket = new WebSocket("ws://127.0.0.1:8081/ws", this._authStore.getUser().token); - exampleSocket.onopen = function (event) { - console.log('Connected', event); - }; - - - } - startWebSocket(): void { + let url = (environment.apiURL + '/ws').replace('https', 'wss'); + url = url.replace('http', 'ws'); let conf = { - url: 'ws://127.0.0.1:8081/ws', - protocol: this._authStore.getUser().token, - headers: { - "ee": "df" - }, + url: url }; this.websocket = new WebSocketSubject(conf); - this.websocket.subscribe((message)=> { + this.websocket.retry().subscribe((message) => { console.log(message); }, (err) => { console.error(err)