From e1f4177694138e6fa7d662947d11d4894ece0fb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20H=C3=A4nel?= Date: Fri, 13 Aug 2021 20:01:02 +0200 Subject: [PATCH] fix error reporting from bridge client --- Assets/Scripts/Components/BridgeClient.cs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Assets/Scripts/Components/BridgeClient.cs b/Assets/Scripts/Components/BridgeClient.cs index 579484065..101211c3e 100644 --- a/Assets/Scripts/Components/BridgeClient.cs +++ b/Assets/Scripts/Components/BridgeClient.cs @@ -41,7 +41,7 @@ public void Connect(string connection) } Connection = connection; - ConnectTime = 0; + ConnectTime = Stopwatch.GetTimestamp(); } public void Update() @@ -64,13 +64,18 @@ public void Update() return; } - // do not reconnect in non interactive mode // do not reconnect in simulation error state // do not reconnect in simulation stopping state if (BridgeStatus == Status.UnexpectedlyDisconnected && - ( Loader.Instance.CurrentSimulation.Interactive == false - || Loader.Instance.Status == SimulatorStatus.Error + (Loader.Instance.Status == SimulatorStatus.Error || Loader.Instance.Status == SimulatorStatus.Stopping)) + { + Bridge.Disconnect(); + Disconnected = true; + } + // do not reconnect in non interactive mode and report error + else if (BridgeStatus == Status.UnexpectedlyDisconnected && + Loader.Instance.CurrentSimulation.Interactive == false) { Loader.Instance.reportStatus(SimulatorStatus.Error, "Bridge socket was unexpectedly disconnected"); Bridge.Disconnect(); @@ -78,18 +83,13 @@ public void Update() } else if (disconnectedStatus) { - if (Stopwatch.GetTimestamp() > ConnectTime || ConnectTime == 0 || Time.timeScale == 0f) + if (Stopwatch.GetTimestamp() >= ConnectTime) { Disconnected = false; Bridge.Connect(Connection); } - else - { - return; - } } - - if (BridgeStatus == Status.Connected) + else if (BridgeStatus == Status.Connected) { Bridge.Update(); }