From c22987d86f3eb697a7bd78d027bd2f2b9288c393 Mon Sep 17 00:00:00 2001 From: "Felix Hartmann (PEA3-Fe-FI)" Date: Thu, 23 Sep 2021 09:52:54 +0200 Subject: [PATCH] fix ip in intial packet (send own ip, not foreign) --- PolyChat/Controller.cs | 3 ++- PolyChat/Models/Connection.cs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/PolyChat/Controller.cs b/PolyChat/Controller.cs index 56c1460..9a187b3 100644 --- a/PolyChat/Controller.cs +++ b/PolyChat/Controller.cs @@ -65,6 +65,7 @@ namespace PolyChat { Debug.WriteLine("--- initial packet received ---"); string ForeignIp = data[0].ToString(); + Debug.WriteLine($"--- this ip was in the inital packet: {ForeignIp} ---"); if (isInConnections(ForeignIp)) { Debug.WriteLine("---- We have an active connection to this client. ABORT! ----");//Todo show error! @@ -128,7 +129,7 @@ namespace PolyChat return false; } - public string getIP() + public static string getIP() { IPHostEntry ipEntry = Dns.GetHostEntry(Dns.GetHostName()); IPAddress[] addrList = ipEntry.AddressList; diff --git a/PolyChat/Models/Connection.cs b/PolyChat/Models/Connection.cs index b1d8600..9c985b6 100644 --- a/PolyChat/Models/Connection.cs +++ b/PolyChat/Models/Connection.cs @@ -58,7 +58,7 @@ namespace PolyChat.Models private void OnConnect() { Debug.WriteLine("--- Sending initial packet to server ---"); - Client.Emit("initial", IP); + Client.Emit("initial", Controller.getIP()); Debug.WriteLine("--- Connection successfull ---"); Connected = true; }