Develop #10

Merged
SemvdH merged 229 commits from develop into master 2020-10-29 22:50:49 +00:00
2 changed files with 18 additions and 6 deletions
Showing only changes of commit d6b938668f - Show all commits

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);

View File

@@ -7,20 +7,22 @@ using System.Net.Sockets;
namespace Client
{
public delegate void HandleSerial(string message);
public delegate void HandleNoTunnelId();
public sealed class EngineConnection
{
private static EngineConnection instance = null;
private static readonly object padlock = new object();
public HandleNoTunnelId OnNoTunnelId;
private static PC[] PCs = {
//new PC("DESKTOP-M2CIH87", "Fabian"),
//new PC("T470S", "Shinichi"),
//new PC("DESKTOP-DHS478C", "semme"),
new PC("HP-ZBOOK-SEM", "Sem"),
new PC("HP-ZBOOK-SEM", "Sem")
//new PC("DESKTOP-TV73FKO", "Wouter"),
new PC("DESKTOP-SINMKT1", "Ralf van Aert"),
//new PC("DESKTOP-SINMKT1", "Ralf van Aert"),
//new PC("NA", "Bart")
};
@@ -62,6 +64,7 @@ namespace Client
{
TcpClient client = new TcpClient("145.48.6.10", 6666);
stream = client.GetStream();
initReader();
CreateConnection();
}
@@ -69,9 +72,8 @@ namespace Client
/// connects to the server and creates the tunnel
/// </summary>
/// <param name="stream">the network stream to use</param>
private void CreateConnection()
public void CreateConnection()
{
initReader();
WriteTextMessage( "{\r\n\"id\" : \"session/list\",\r\n\"serial\" : \"list\"\r\n}");
@@ -119,6 +121,8 @@ namespace Client
if (tunnelId == null)
{
Write("could not find a valid tunnel id!");
OnNoTunnelId?.Invoke();
Connected = false;
return;
}
}