From 0761f1bf8c62679c40a1e713cd3a6723ff7f24f2 Mon Sep 17 00:00:00 2001 From: Baptiste Clarey Sjostrand <112877883+baphony@users.noreply.github.com> Date: Wed, 15 Mar 2023 09:46:48 +0100 Subject: [PATCH] RTC-13903 Fix C9 double network messages on virtual machine --- src/app/c9-shell-handler.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/app/c9-shell-handler.ts b/src/app/c9-shell-handler.ts index a1d6401e..2e925810 100644 --- a/src/app/c9-shell-handler.ts +++ b/src/app/c9-shell-handler.ts @@ -19,6 +19,7 @@ type StatusCallback = (status: IShellStatus) => void; class C9ShellHandler { private _c9shell: ChildProcess | undefined; private _curStatus: IShellStatus | undefined; + private _firstSuccessfulConnectionDate = 0; private _isDisconnected = false; private _isFreshStart = true; private _isStarting = false; @@ -239,10 +240,18 @@ class C9ShellHandler { if ( c9ShellMessage.includes('NetworkConnectivityService|Internet Available') ) { - this._isFreshStart = false; + if (this._isFreshStart) { + this._isFreshStart = false; + this._firstSuccessfulConnectionDate = Date.now(); + } if (this._isDisconnected) { this._isDisconnected = false; - this._onNetworkReconnection(); + const millisecondsElapsed = + Date.now() - this._firstSuccessfulConnectionDate; + // Sometime, we have 2 network connections in 4 seconds (while using a virtual machine) + if (millisecondsElapsed > 10000) { + this._onNetworkReconnection(); + } } } else if ( c9ShellMessage.includes(