From 014191b350144c638093b7ab1dc169a64e0a3ade Mon Sep 17 00:00:00 2001 From: Sem van der Hoeven Date: Fri, 16 Oct 2020 11:27:12 +0200 Subject: [PATCH 1/2] smol fix --- ClientApp/Utils/EngineConnection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ClientApp/Utils/EngineConnection.cs b/ClientApp/Utils/EngineConnection.cs index a82dfb7..8f2dca7 100644 --- a/ClientApp/Utils/EngineConnection.cs +++ b/ClientApp/Utils/EngineConnection.cs @@ -298,7 +298,7 @@ namespace ClientApp.Utils { // TODO check if is drawn }); - SendMessageAndOnResponse(stream, mainCommand.showMessage(panelId, "message", lastMessage), "message", + SendMessageAndOnResponse(mainCommand.showMessage(panelId, "message", lastMessage), "message", (message) => { // TODO check if is drawn From 2f81f32a036976e274b2133780b3bdd5c370f7f8 Mon Sep 17 00:00:00 2001 From: Sem van der Hoeven Date: Fri, 16 Oct 2020 12:15:58 +0200 Subject: [PATCH 2/2] added checking for response from vr engine and automatic reconnect --- ClientApp/Utils/Client.cs | 1 + ClientApp/Utils/EngineConnection.cs | 34 +++++++++++++++++++++++++---- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/ClientApp/Utils/Client.cs b/ClientApp/Utils/Client.cs index e292e0e..90d17a9 100644 --- a/ClientApp/Utils/Client.cs +++ b/ClientApp/Utils/Client.cs @@ -46,6 +46,7 @@ namespace ClientApp.Utils engineConnection = EngineConnection.INSTANCE; engineConnection.OnNoTunnelId = RetryEngineConnection; engineConnection.OnSuccessFullConnection = engineConnected; + engineConnection.OnEngineDisconnect = RetryEngineConnection; if (!engineConnection.Connected) engineConnection.Connect(); } diff --git a/ClientApp/Utils/EngineConnection.cs b/ClientApp/Utils/EngineConnection.cs index 8f2dca7..3706e87 100644 --- a/ClientApp/Utils/EngineConnection.cs +++ b/ClientApp/Utils/EngineConnection.cs @@ -10,16 +10,17 @@ using LibNoise.Primitive; namespace ClientApp.Utils { public delegate void HandleSerial(string message); - public delegate void HandleNoTunnelId(); - public delegate void OnSuccessfullConnection(); + public delegate void EngineDelegate(); public sealed class EngineConnection { private static EngineConnection instance = null; private static readonly object padlock = new object(); private static System.Timers.Timer updateTimer; - public HandleNoTunnelId OnNoTunnelId; - public OnSuccessfullConnection OnSuccessFullConnection; + private static System.Timers.Timer noVRResponseTimer; + public EngineDelegate OnNoTunnelId; + public EngineDelegate OnSuccessFullConnection; + public EngineDelegate OnEngineDisconnect; private static PC[] PCs = { @@ -68,6 +69,12 @@ namespace ClientApp.Utils updateTimer.Elapsed += UpdateTimer_Elapsed; updateTimer.AutoReset = true; updateTimer.Enabled = false; + + noVRResponseTimer = new System.Timers.Timer(15000); + noVRResponseTimer.Elapsed += noVRResponseTimeout; + noVRResponseTimer.AutoReset = false; + noVRResponseTimer.Enabled = false; + } private void UpdateTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) @@ -75,6 +82,21 @@ namespace ClientApp.Utils UpdateInfoPanel(); } + private void noVRResponseTimeout(object sender, System.Timers.ElapsedEventArgs e) + { + Write("VR RESPONSE TIMEOUT"); + noVRResponseTimer.Stop(); + sessionId = string.Empty; + tunnelId = string.Empty; + cameraId = string.Empty; + routeId = string.Empty; + panelId = string.Empty; + bikeId = string.Empty; + groundPlaneId = string.Empty; + terrainId = string.Empty; + OnEngineDisconnect?.Invoke(); + } + /// /// Singleton constructor /// @@ -166,6 +188,7 @@ namespace ClientApp.Utils { Write("got tunnel id! " + tunnelId); Connected = true; + noVRResponseTimer.Enabled = true; OnSuccessFullConnection?.Invoke(); } } @@ -177,6 +200,9 @@ namespace ClientApp.Utils //Console.WriteLine("Got serial " + serial); if (serialResponses.ContainsKey(serial)) serialResponses[serial].Invoke(message); } + + noVRResponseTimer.Stop(); + noVRResponseTimer.Start(); } public void initScene()