From c24016c8b3b426836c375e4ba5d4523e32d960c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Gerrit=20G=C3=B6bel?= <86782124+jggoebel@users.noreply.github.com> Date: Fri, 26 Apr 2024 13:03:35 +0200 Subject: [PATCH] unsubscribe CTRstream if socket reloads or fails (#201) --- src/app/scenario/terminal.component.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/app/scenario/terminal.component.ts b/src/app/scenario/terminal.component.ts index 4a01c55b..c1dd6543 100644 --- a/src/app/scenario/terminal.component.ts +++ b/src/app/scenario/terminal.component.ts @@ -136,6 +136,8 @@ export class TerminalComponent implements OnChanges, AfterViewInit, OnDestroy { ); // we're going to try and rebuild things // but only after waiting an appropriate mourning period... + this.subscription.unsubscribe(); + this.subscription = new Subscription(); this.subscription.add(timer(5000).subscribe(() => this.buildSocket())); } }; @@ -172,6 +174,9 @@ export class TerminalComponent implements OnChanges, AfterViewInit, OnDestroy { private closeSocket() { if (!this.socket) return; + if (this.subscription) { + this.subscription.unsubscribe(); + } this.socket.close(WS_CODE_NORMAL_CLOSURE); }