RTC-13903 Fix C9 double network messages on virtual machine

This commit is contained in:
Baptiste Clarey Sjostrand 2023-03-15 09:46:48 +01:00 committed by Salah Benmoussati
parent b2f230121e
commit 0761f1bf8c

View File

@ -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,11 +240,19 @@ class C9ShellHandler {
if (
c9ShellMessage.includes('NetworkConnectivityService|Internet Available')
) {
if (this._isFreshStart) {
this._isFreshStart = false;
this._firstSuccessfulConnectionDate = Date.now();
}
if (this._isDisconnected) {
this._isDisconnected = false;
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(
'NetworkConnectivityService|No Internet Available',