diff options
author | Dessalines <tyhou13@gmx.com> | 2020-02-04 11:19:05 -0500 |
---|---|---|
committer | Dessalines <tyhou13@gmx.com> | 2020-02-04 11:19:05 -0500 |
commit | b0b50098a4079daa0622a1ff9b4c52774d1d1d9f (patch) | |
tree | 527c63d46ae091558d0195915972a6b81cf7963c /ui/src/services | |
parent | e4dfa5e52f911a6dbb5df41932a70dd9af3c9753 (diff) |
Websocket reconnect reload page data. Fixes #504
Diffstat (limited to 'ui/src/services')
-rw-r--r-- | ui/src/services/WebSocketService.ts | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/ui/src/services/WebSocketService.ts b/ui/src/services/WebSocketService.ts index c5e45e79..6d951618 100644 --- a/ui/src/services/WebSocketService.ts +++ b/ui/src/services/WebSocketService.ts @@ -40,6 +40,7 @@ import { GetPrivateMessagesForm, UserJoinForm, MessageType, + WebSocketJsonResponse, } from '../interfaces'; import { UserService } from './'; import { i18n } from '../i18next'; @@ -59,17 +60,21 @@ export class WebSocketService { private constructor() { this.ws = new ReconnectingWebSocket(wsUri); - this.ws.onopen = () => { - console.log(`Connected to ${wsUri}`); - if (UserService.Instance.user) { - this.userJoin(); - } - }; this.subject = Observable.create((obs: any) => { this.ws.onmessage = e => { obs.next(JSON.parse(e.data)); }; + this.ws.onopen = () => { + console.log(`Connected to ${wsUri}`); + if (UserService.Instance.user) { + this.userJoin(); + } + let res: WebSocketJsonResponse = { + reconnect: true, + }; + obs.next(res); + }; }).pipe(share()); } |