Develop #10
@@ -46,6 +46,7 @@ namespace ClientApp.Utils
|
|||||||
engineConnection = EngineConnection.INSTANCE;
|
engineConnection = EngineConnection.INSTANCE;
|
||||||
engineConnection.OnNoTunnelId = RetryEngineConnection;
|
engineConnection.OnNoTunnelId = RetryEngineConnection;
|
||||||
engineConnection.OnSuccessFullConnection = engineConnected;
|
engineConnection.OnSuccessFullConnection = engineConnected;
|
||||||
|
engineConnection.OnEngineDisconnect = RetryEngineConnection;
|
||||||
if (!engineConnection.Connected) engineConnection.Connect();
|
if (!engineConnection.Connected) engineConnection.Connect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,16 +10,17 @@ using LibNoise.Primitive;
|
|||||||
namespace ClientApp.Utils
|
namespace ClientApp.Utils
|
||||||
{
|
{
|
||||||
public delegate void HandleSerial(string message);
|
public delegate void HandleSerial(string message);
|
||||||
public delegate void HandleNoTunnelId();
|
public delegate void EngineDelegate();
|
||||||
public delegate void OnSuccessfullConnection();
|
|
||||||
|
|
||||||
public sealed class EngineConnection
|
public sealed class EngineConnection
|
||||||
{
|
{
|
||||||
private static EngineConnection instance = null;
|
private static EngineConnection instance = null;
|
||||||
private static readonly object padlock = new object();
|
private static readonly object padlock = new object();
|
||||||
private static System.Timers.Timer updateTimer;
|
private static System.Timers.Timer updateTimer;
|
||||||
public HandleNoTunnelId OnNoTunnelId;
|
private static System.Timers.Timer noVRResponseTimer;
|
||||||
public OnSuccessfullConnection OnSuccessFullConnection;
|
public EngineDelegate OnNoTunnelId;
|
||||||
|
public EngineDelegate OnSuccessFullConnection;
|
||||||
|
public EngineDelegate OnEngineDisconnect;
|
||||||
|
|
||||||
|
|
||||||
private static PC[] PCs = {
|
private static PC[] PCs = {
|
||||||
@@ -68,6 +69,12 @@ namespace ClientApp.Utils
|
|||||||
updateTimer.Elapsed += UpdateTimer_Elapsed;
|
updateTimer.Elapsed += UpdateTimer_Elapsed;
|
||||||
updateTimer.AutoReset = true;
|
updateTimer.AutoReset = true;
|
||||||
updateTimer.Enabled = false;
|
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)
|
private void UpdateTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
|
||||||
@@ -75,6 +82,21 @@ namespace ClientApp.Utils
|
|||||||
UpdateInfoPanel();
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Singleton constructor
|
/// Singleton constructor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -166,6 +188,7 @@ namespace ClientApp.Utils
|
|||||||
{
|
{
|
||||||
Write("got tunnel id! " + tunnelId);
|
Write("got tunnel id! " + tunnelId);
|
||||||
Connected = true;
|
Connected = true;
|
||||||
|
noVRResponseTimer.Enabled = true;
|
||||||
OnSuccessFullConnection?.Invoke();
|
OnSuccessFullConnection?.Invoke();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -177,6 +200,9 @@ namespace ClientApp.Utils
|
|||||||
//Console.WriteLine("Got serial " + serial);
|
//Console.WriteLine("Got serial " + serial);
|
||||||
if (serialResponses.ContainsKey(serial)) serialResponses[serial].Invoke(message);
|
if (serialResponses.ContainsKey(serial)) serialResponses[serial].Invoke(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
noVRResponseTimer.Stop();
|
||||||
|
noVRResponseTimer.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initScene()
|
public void initScene()
|
||||||
|
|||||||
Reference in New Issue
Block a user