added reconnecting to the vr server when no tunnel id is found

This commit is contained in:
Sem van der Hoeven
2020-09-30 14:33:15 +02:00
parent 341723d1d1
commit d6b938668f
2 changed files with 18 additions and 6 deletions

View File

@@ -27,16 +27,24 @@ namespace Client
this.client = new TcpClient();
this.connected = false;
client.BeginConnect(adress, port, new AsyncCallback(OnConnect), null);
initEngine();
}
private void initEngine()
{
engineConnection = EngineConnection.INSTANCE;
engineConnection.OnNoTunnelId = retryEngineConnection;
if (!engineConnection.Connected) engineConnection.Connect();
}
private void retryEngineConnection()
{
Console.WriteLine("Could not connect to the VR engine. Please make sure you are running the simulation!");
Console.WriteLine("Press any key to retry connection");
Console.ReadKey();
engineConnection.CreateConnection();
}
private void OnConnect(IAsyncResult ar)
{
this.client.EndConnect(ar);