diff --git a/ClientApp/Utils/Client.cs b/ClientApp/Utils/Client.cs index ac4ae99..f702f2e 100644 --- a/ClientApp/Utils/Client.cs +++ b/ClientApp/Utils/Client.cs @@ -4,7 +4,7 @@ using System.Net.Sockets; using System.Text; using ProftaakRH; -namespace Client +namespace ClientApp.Utils { public class Client : IDataReceiver { @@ -79,8 +79,6 @@ namespace Client this.stream = this.client.GetStream(); - tryLogin(); - this.stream.BeginRead(this.buffer, 0, this.buffer.Length, new AsyncCallback(OnRead), null); } diff --git a/ClientApp/Utils/DataParser.cs b/ClientApp/Utils/DataParser.cs index 8eddb4c..6c1e4b7 100644 --- a/ClientApp/Utils/DataParser.cs +++ b/ClientApp/Utils/DataParser.cs @@ -6,7 +6,7 @@ using System.Linq; using System.Runtime.InteropServices.WindowsRuntime; using System.Text; -namespace Client +namespace ClientApp.Utils { public class DataParser { diff --git a/ClientApp/Utils/EngineConnection.cs b/ClientApp/Utils/EngineConnection.cs index 9d0d4e5..a4dd657 100644 --- a/ClientApp/Utils/EngineConnection.cs +++ b/ClientApp/Utils/EngineConnection.cs @@ -4,7 +4,7 @@ using System.Text; using RH_Engine; using System.Net.Sockets; -namespace Client +namespace ClientApp.Utils { public delegate void HandleSerial(string message); public delegate void HandleNoTunnelId(); @@ -77,7 +77,7 @@ namespace Client } } - + /// /// connects to the vr engine and initalizes the serverResponseReader @@ -109,7 +109,7 @@ namespace Client public void CreateConnection() { - WriteTextMessage( "{\r\n\"id\" : \"session/list\",\r\n\"serial\" : \"list\"\r\n}"); + WriteTextMessage("{\r\n\"id\" : \"session/list\",\r\n\"serial\" : \"list\"\r\n}"); // wait until we have got a sessionId while (sessionId == string.Empty) { } @@ -145,7 +145,8 @@ namespace Client Connected = false; FollowingRoute = false; return; - } else + } + else { Write("got tunnel id! " + tunnelId); Connected = true; @@ -270,7 +271,8 @@ namespace Client if (serialResponses.ContainsKey(serial)) { serialResponses[serial] = action; - } else + } + else { serialResponses.Add(serial, action); } @@ -300,11 +302,11 @@ namespace Client public void Stop() { serverResponseReader.Stop(); - + } public void Write(string msg) { - Console.WriteLine( "[ENGINECONNECT] " + msg); + Console.WriteLine("[ENGINECONNECT] " + msg); } } diff --git a/ClientApp/Utils/Program.cs b/ClientApp/Utils/Program.cs index 289bcd4..ecab577 100644 --- a/ClientApp/Utils/Program.cs +++ b/ClientApp/Utils/Program.cs @@ -5,7 +5,7 @@ using RH_Engine; using System.Security.Cryptography; using System.Text; -namespace Client +namespace ClientApp.Utils { class Program { diff --git a/ClientApp/Views/MainWindow.xaml.cs b/ClientApp/Views/MainWindow.xaml.cs index 49d8058..1208afd 100644 --- a/ClientApp/Views/MainWindow.xaml.cs +++ b/ClientApp/Views/MainWindow.xaml.cs @@ -15,7 +15,7 @@ using System.Windows.Navigation; using System.Windows.Shapes; using ClientApp.Utils; using Hardware.Simulators; -using Client; +using System.Threading; namespace ClientApp { @@ -25,15 +25,19 @@ namespace ClientApp public partial class MainWindow : Window { public MainWindow() + { - InitializeComponent(); - DataContext = new MainWindowViewModel(); + System.Diagnostics.Debug.WriteLine("derp1"); Client client = new Client(); - while (!client.IsConnected()) - { + System.Diagnostics.Debug.WriteLine("derp2"); + + + InitializeComponent(); + DataContext = new MainWindowViewModel(); + System.Diagnostics.Debug.WriteLine("derp3"); + - } //BLEHandler bLEHandler = new BLEHandler(client); //bLEHandler.Connect(); @@ -42,10 +46,18 @@ namespace ClientApp BikeSimulator bikeSimulator = new BikeSimulator(client); + System.Diagnostics.Debug.WriteLine("derp4"); + + Thread newThread = new Thread(new ThreadStart(bikeSimulator.StartSimulation)); + newThread.Start(); + //bikeSimulator.StartSimulation(); + System.Diagnostics.Debug.WriteLine("derp5"); - bikeSimulator.StartSimulation(); client.setHandler(bikeSimulator); + System.Diagnostics.Debug.WriteLine("derp6"); + + } } } diff --git a/ProftaakRH/ProftaakRH.sln b/ProftaakRH/ProftaakRH.sln index b96b151..b0e786f 100644 --- a/ProftaakRH/ProftaakRH.sln +++ b/ProftaakRH/ProftaakRH.sln @@ -9,8 +9,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RH-Engine", "..\RH-Engine\R EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Server", "..\Server\Server.csproj", "{B1AB6F51-A20D-4162-9A7F-B3350B7510FD}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Client", "..\Client\Client.csproj", "{5759DD20-7A4F-4D8D-B986-A70A7818C112}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Message", "..\Message\Message.csproj", "{9ED6832D-B0FB-4460-9BCD-FAA58863B0CE}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DokterApp", "..\DokterApp\DokterApp.csproj", "{B150F08B-13DA-4D17-BD96-7E89F52727C6}" @@ -22,7 +20,6 @@ EndProject Global GlobalSection(SharedMSBuildProjectFiles) = preSolution ..\Hashing\Hashing.projitems*{013aadba-1d27-4a52-81d8-217697e91039}*SharedItemsImports = 5 - ..\Hashing\Hashing.projitems*{5759dd20-7a4f-4d8d-b986-a70a7818c112}*SharedItemsImports = 5 ..\Hashing\Hashing.projitems*{70277749-d423-4871-b692-2efc5a6ed932}*SharedItemsImports = 13 ..\Hashing\Hashing.projitems*{b1ab6f51-a20d-4162-9a7f-b3350b7510fd}*SharedItemsImports = 5 EndGlobalSection @@ -43,10 +40,6 @@ Global {B1AB6F51-A20D-4162-9A7F-B3350B7510FD}.Debug|Any CPU.Build.0 = Debug|Any CPU {B1AB6F51-A20D-4162-9A7F-B3350B7510FD}.Release|Any CPU.ActiveCfg = Release|Any CPU {B1AB6F51-A20D-4162-9A7F-B3350B7510FD}.Release|Any CPU.Build.0 = Release|Any CPU - {5759DD20-7A4F-4D8D-B986-A70A7818C112}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {5759DD20-7A4F-4D8D-B986-A70A7818C112}.Debug|Any CPU.Build.0 = Debug|Any CPU - {5759DD20-7A4F-4D8D-B986-A70A7818C112}.Release|Any CPU.ActiveCfg = Release|Any CPU - {5759DD20-7A4F-4D8D-B986-A70A7818C112}.Release|Any CPU.Build.0 = Release|Any CPU {9ED6832D-B0FB-4460-9BCD-FAA58863B0CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {9ED6832D-B0FB-4460-9BCD-FAA58863B0CE}.Debug|Any CPU.Build.0 = Debug|Any CPU {9ED6832D-B0FB-4460-9BCD-FAA58863B0CE}.Release|Any CPU.ActiveCfg = Release|Any CPU diff --git a/Server/Client.cs b/Server/Client.cs index 3fa7ba0..ef173ec 100644 --- a/Server/Client.cs +++ b/Server/Client.cs @@ -1,11 +1,9 @@ using System; using System.IO; -using System.Linq; using System.Net.Sockets; using System.Text; -using Client; using Newtonsoft.Json; -using System.Security.Cryptography; +using ClientApp.Utils; namespace Server { diff --git a/Server/Server.csproj b/Server/Server.csproj index cd7c7da..0338a27 100644 --- a/Server/Server.csproj +++ b/Server/Server.csproj @@ -10,7 +10,7 @@ - +