From 4bf8032003d29716891f6c34f0181a5e2e4dc520 Mon Sep 17 00:00:00 2001 From: SCM6WE Date: Tue, 21 Sep 2021 08:35:00 +0200 Subject: [PATCH 1/5] min version to 1903 --- PolyChat/PolyChat.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PolyChat/PolyChat.csproj b/PolyChat/PolyChat.csproj index 6119e13..f81e50a 100644 --- a/PolyChat/PolyChat.csproj +++ b/PolyChat/PolyChat.csproj @@ -12,7 +12,7 @@ en-US UAP 10.0.19041.0 - 10.0.19041.0 + 10.0.18362.0 14 512 {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} From 5d69842ec03c94e4789fdfef1f406925010e8cf8 Mon Sep 17 00:00:00 2001 From: "Hartmann Felix (PEA3-Fe-FI)" Date: Tue, 21 Sep 2021 08:52:53 +0200 Subject: [PATCH 2/5] use string for IP adresses instead of explicit type --- PolyChat/Controller.cs | 11 ++++++++--- PolyChat/Models/MSG.cs | 8 ++++---- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/PolyChat/Controller.cs b/PolyChat/Controller.cs index 850c213..1f9dc34 100644 --- a/PolyChat/Controller.cs +++ b/PolyChat/Controller.cs @@ -12,7 +12,7 @@ namespace PolyChat { public class Controller { - public static IPAddress ip; + public static string ip; private MainPage UIController; private ClientHandler clientHandler; @@ -93,11 +93,16 @@ namespace PolyChat Console.WriteLine($"Message received from {socket.GetHashCode()}:{message.Data[0]}"); } - static IPAddress[] GetIPs() + static string[] GetIPs() { IPHostEntry ipEntry = Dns.GetHostEntry(Dns.GetHostName()); IPAddress[] addr = ipEntry.AddressList; - return addr; + string[] ips = new string[addr.Length]; + for (int i=0; i public class MSG { - public String sender = "unknown"; + public string sender = "unknown"; public DateTime timestamp = new DateTime(2000, 01, 01); - public String msg = "empty"; - public IPAddress ip = new IPAddress(new byte[] { 49,48,46,49,46,50,49,49,46,50,54 }); + public string msg = "empty"; + public string ip; - public MSG(String sender, IPAddress ip, String msg, DateTime timestamp) + public MSG(string sender, string ip, String msg, DateTime timestamp) { this.sender = sender; this.ip = ip; From d42acbc90ebb529c2d1cab3d83383cddb40f135a Mon Sep 17 00:00:00 2001 From: "Felix Hartmann (PEA3-Fe-FI)" Date: Tue, 21 Sep 2021 09:28:29 +0200 Subject: [PATCH 3/5] remove MSG.cs, merge content from MSG.cs and ChatMessage.cs, refactor code --- PolyChat/MainPage.xaml | 4 ++-- PolyChat/MainPage.xaml.cs | 13 +++++++------ PolyChat/Models/ChatMessage.cs | 26 +++++++++++++++++--------- PolyChat/Models/Client.cs | 6 +++--- PolyChat/Models/MSG.cs | 29 ----------------------------- PolyChat/PolyChat.csproj | 1 - 6 files changed, 29 insertions(+), 50 deletions(-) delete mode 100644 PolyChat/Models/MSG.cs diff --git a/PolyChat/MainPage.xaml b/PolyChat/MainPage.xaml index 8439a3e..0887502 100644 --- a/PolyChat/MainPage.xaml +++ b/PolyChat/MainPage.xaml @@ -90,8 +90,8 @@ - - + + diff --git a/PolyChat/MainPage.xaml.cs b/PolyChat/MainPage.xaml.cs index b0b8e00..2e26594 100644 --- a/PolyChat/MainPage.xaml.cs +++ b/PolyChat/MainPage.xaml.cs @@ -38,8 +38,8 @@ namespace PolyChat public void OnSendMessage(object sender = null, RoutedEventArgs e = null) { selectedPartner.AddMessage(new ChatMessage( + DateTime.Now, inputSend.Text, - DateTime.Now.ToString(), false )); Controller.sendMessage(selectedPartner.Code, inputUsername.Text, inputSend.Text); @@ -62,13 +62,14 @@ namespace PolyChat } } - public void OnIncomingMessage(MSG message) + public void OnIncomingMessage(ChatMessage message) { - ChatPartner sendingPartner = Partners.First(p => p.Code == message.ip.ToString()); + ChatPartner sendingPartner = Partners.First(p => p.Code == message.Ip); sendingPartner.AddMessage(new ChatMessage( - message.msg, - message.timestamp.ToString(), - true + message.Timestamp, + message.Msg, + true, + message.Sender )); } diff --git a/PolyChat/Models/ChatMessage.cs b/PolyChat/Models/ChatMessage.cs index b429318..e2ebb6d 100644 --- a/PolyChat/Models/ChatMessage.cs +++ b/PolyChat/Models/ChatMessage.cs @@ -1,23 +1,31 @@ -namespace PolyChat.Models +using System; + +namespace PolyChat.Models { public class ChatMessage { - public string Text; - public string Date; - public bool Foreign; + public readonly string Sender; + public readonly DateTime Timestamp = new DateTime(1970, 01, 01); + public readonly string Msg = "empty"; + public readonly string Ip; + public readonly bool Foreign; + public readonly string StringTimeStamp; - public ChatMessage(string text, string date, bool foreign) + public ChatMessage(DateTime Timestamp, string Msg, bool Foreign = true, string Sender= "Unknown", string Ip = "127.0.0.1") { - Text = text; - Date = date; - Foreign = foreign; + this.Sender = Sender; + this.Timestamp = Timestamp; + StringTimeStamp = Timestamp.ToString(); + this.Msg = Msg; + this.Foreign = Foreign; + this.Ip = Ip; } override public string ToString() { string prefix = Foreign ? "Other" : "Me"; - return $"{prefix}: Text"; + return $"{prefix}: {Msg}({Sender})"; } } } \ No newline at end of file diff --git a/PolyChat/Models/Client.cs b/PolyChat/Models/Client.cs index 0b2967e..194d2db 100644 --- a/PolyChat/Models/Client.cs +++ b/PolyChat/Models/Client.cs @@ -24,7 +24,7 @@ namespace PolyChat.Models { private SocketIOClient connection; public Boolean isConnected = false; - private List msgStack = new List(); + private List msgStack = new List(); private Boolean active = true; private String ip; @@ -49,7 +49,7 @@ namespace PolyChat.Models new Thread(() => { //create msg - MSG msg = new MSG(sender, Controller.ip, chatMessage, timestamp); + ChatMessage msg = new ChatMessage(timestamp, chatMessage, false, sender, Controller.ip); //convert msg String petJson = JsonNet.Serialize(msg); @@ -78,7 +78,7 @@ namespace PolyChat.Models { connection.On(SendCode.Message.ToString(), (Data) => { - MSG pet = JsonNet.Deserialize(BitConverter.ToString(Data[0].ToObject())); + ChatMessage pet = JsonNet.Deserialize(BitConverter.ToString(Data[0].ToObject())); //TODO: send message to GUI }); connection.On(SendCode.Command.ToString(), (Data) => diff --git a/PolyChat/Models/MSG.cs b/PolyChat/Models/MSG.cs deleted file mode 100644 index 95dae94..0000000 --- a/PolyChat/Models/MSG.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net; -using System.Text; -using System.Threading.Tasks; - -namespace PolyChat.Models -{ - /// - /// dumy class for json converter - /// - public class MSG - { - public string sender = "unknown"; - public DateTime timestamp = new DateTime(2000, 01, 01); - public string msg = "empty"; - public string ip; - - - public MSG(string sender, string ip, String msg, DateTime timestamp) - { - this.sender = sender; - this.ip = ip; - this.timestamp = timestamp; - this.msg = msg; - } - } -} diff --git a/PolyChat/PolyChat.csproj b/PolyChat/PolyChat.csproj index f81e50a..1393077 100644 --- a/PolyChat/PolyChat.csproj +++ b/PolyChat/PolyChat.csproj @@ -127,7 +127,6 @@ - From 697a7ad50687785db7d1150736c65a38ce99a3ae Mon Sep 17 00:00:00 2001 From: SCM6WE Date: Tue, 21 Sep 2021 10:12:29 +0200 Subject: [PATCH 4/5] merge --- PolyChat/Controller.cs | 5 +- PolyChat/MainPage.xaml.cs | 10 +-- PolyChat/Models/ChatMessage.cs | 6 +- PolyChat/Models/Client.cs | 67 ++++++++------- PolyChat/Models/MSG.cs | 29 +++++++ PolyChat/Models/NetworkingController.cs | 103 ++++++++++++++++++++++++ PolyChat/Models/SendCode.cs | 4 +- PolyChat/Models/Socket.cs | 8 +- PolyChat/PolyChat.csproj | 1 + 9 files changed, 188 insertions(+), 45 deletions(-) create mode 100644 PolyChat/Models/MSG.cs create mode 100644 PolyChat/Models/NetworkingController.cs diff --git a/PolyChat/Controller.cs b/PolyChat/Controller.cs index 1f9dc34..6877d93 100644 --- a/PolyChat/Controller.cs +++ b/PolyChat/Controller.cs @@ -16,6 +16,7 @@ namespace PolyChat private MainPage UIController; private ClientHandler clientHandler; + /* public Controller(MainPage uiController) { UIController = uiController; @@ -30,9 +31,9 @@ namespace PolyChat public void sendMessage(String ip, String name, String msg) { - clientHandler.getClient(ip).sendMessage(SendCode.Message, name, msg, DateTime.Now); + clientHandler.getClient(ip).sendMessage(SendCode.Message, msg, DateTime.Now); } - + */ /// /// prints out ip. on server side automatticaly finds 10.... ip (which is the correct one) /// diff --git a/PolyChat/MainPage.xaml.cs b/PolyChat/MainPage.xaml.cs index 2e26594..5809139 100644 --- a/PolyChat/MainPage.xaml.cs +++ b/PolyChat/MainPage.xaml.cs @@ -16,13 +16,13 @@ namespace PolyChat /// public sealed partial class MainPage : Page { - private Controller Controller; + private NetworkingController networkingController; private ObservableCollection Partners; private ChatPartner selectedPartner; public MainPage() { this.InitializeComponent(); - Controller = new Controller(this); + networkingController = new NetworkingController(this); Partners = new ObservableCollection(); } @@ -38,11 +38,10 @@ namespace PolyChat public void OnSendMessage(object sender = null, RoutedEventArgs e = null) { selectedPartner.AddMessage(new ChatMessage( - DateTime.Now, inputSend.Text, false )); - Controller.sendMessage(selectedPartner.Code, inputUsername.Text, inputSend.Text); + networkingController.sendMessage(selectedPartner.Code, inputSend.Text); // clear input inputSend.Text = ""; } @@ -54,7 +53,7 @@ namespace PolyChat if (result == ContentDialogResult.Primary) { string ip = dialog.getText(); - Controller.Connect(ip); + networkingController.connectNewClient(ip); Partners.Add(new ChatPartner( "NO NAME", ip @@ -66,7 +65,6 @@ namespace PolyChat { ChatPartner sendingPartner = Partners.First(p => p.Code == message.Ip); sendingPartner.AddMessage(new ChatMessage( - message.Timestamp, message.Msg, true, message.Sender diff --git a/PolyChat/Models/ChatMessage.cs b/PolyChat/Models/ChatMessage.cs index e2ebb6d..96ad8ff 100644 --- a/PolyChat/Models/ChatMessage.cs +++ b/PolyChat/Models/ChatMessage.cs @@ -11,16 +11,18 @@ namespace PolyChat.Models public readonly bool Foreign; public readonly string StringTimeStamp; - public ChatMessage(DateTime Timestamp, string Msg, bool Foreign = true, string Sender= "Unknown", string Ip = "127.0.0.1") + public ChatMessage(string Msg = "", bool Foreign = true, string Sender= "Unknown", string Ip = "127.0.0.1") { this.Sender = Sender; - this.Timestamp = Timestamp; + this.Timestamp = DateTime.Now; StringTimeStamp = Timestamp.ToString(); this.Msg = Msg; this.Foreign = Foreign; this.Ip = Ip; } + + override public string ToString() { diff --git a/PolyChat/Models/Client.cs b/PolyChat/Models/Client.cs index 194d2db..e2df56e 100644 --- a/PolyChat/Models/Client.cs +++ b/PolyChat/Models/Client.cs @@ -10,12 +10,7 @@ using SocketIOSharp.Server.Client; using EngineIOSharp.Common.Enum; using Json.Net; using System.Net; -using SocketIOSharp.Client; -using SocketIOSharp.Common; using SocketIOSharp.Common.Packet; -using System; -using System.Net; -using EngineIOSharp.Common.Enum; using System.Threading; namespace PolyChat.Models @@ -23,18 +18,18 @@ namespace PolyChat.Models class Client { private SocketIOClient connection; - public Boolean isConnected = false; - private List msgStack = new List(); - private Boolean active = true; - private String ip; + private Boolean connected = false; + private String ipSelf; public Client(SocketIOClient connection, String ip) { - this.ip = ip; + this.ipSelf = ip; this.connection = connection; InitEventHandlers(this, connection); } + //Sending + //=================================================================================== /// /// converts String message into json file and sends it to the server. /// @@ -44,12 +39,12 @@ namespace PolyChat.Models /// Sender of Message /// the accual text the user wants to send /// current time - public void sendMessage(SendCode code, String sender, String chatMessage, DateTime timestamp) + public void sendMessage(SendCode code, String chatMessage) { new Thread(() => { //create msg - ChatMessage msg = new ChatMessage(timestamp, chatMessage, false, sender, Controller.ip); + ChatMessage msg = new ChatMessage(chatMessage, false, Controller.ip); //convert msg String petJson = JsonNet.Serialize(msg); @@ -59,16 +54,31 @@ namespace PolyChat.Models }).Start(); } - /* - private void recieveMessage(String msg) + /// + /// Sends Message with new name + /// + /// + /// + /// + public void sendNameChange(SendCode code, String nameChange) { - // deserialize json string - MSG pet = JsonNet.Deserialize(msg); + new Thread(() => + { + //create msg + ChatMessage msg = new ChatMessage( Controller.ip); - //TODO: send message to GUI + //convert msg + String petJson = JsonNet.Serialize(msg); + + //send msg + connection.Emit(code.ToString(), petJson); + }).Start(); } - */ + //================================================================================== + //EventHandeling + //=================================================================================== + /// /// handles all events of client server communiation /// @@ -85,25 +95,24 @@ namespace PolyChat.Models { Console.WriteLine("Command recieved!" + Data[0]); }); - connection.On(SendCode.test1.ToString(), (Data) => - { - Console.WriteLine("test1 recieved!" + Data[0]); - }); - connection.On(SendCode.test2.ToString(), (Data) => - { - Console.WriteLine("test2 recieved!" + Data[0]); - }); connection.On(SocketIOEvent.CONNECTION, () => { - Console.WriteLine("Connected!"); - client.isConnected = true; + client.connected = true; }); } + //================================================================================== + //Getter and Setter + //================================================================================== public String getIP() { - return this.ip; + return this.ipSelf; + } + + public Boolean isConnected() + { + return this.connected; } } diff --git a/PolyChat/Models/MSG.cs b/PolyChat/Models/MSG.cs new file mode 100644 index 0000000..637fc3b --- /dev/null +++ b/PolyChat/Models/MSG.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Text; +using System.Threading.Tasks; + +namespace PolyChat.Models +{ + /// + /// dumy class for json converter + /// + public class MSG + { + public String sender = "unknown"; + public DateTime timestamp = new DateTime(2000, 01, 01); + public String msg = "empty"; + public IPAddress ip = new IPAddress(new byte[] { 49,48,46,49,46,50,49,49,46,50,54 }); + + + public MSG(IPAddress ip, String msg, DateTime timestamp) + { + this.sender = sender; + this.ip = ip; + this.timestamp = timestamp; + this.msg = msg; + } + } +} diff --git a/PolyChat/Models/NetworkingController.cs b/PolyChat/Models/NetworkingController.cs new file mode 100644 index 0000000..90183ba --- /dev/null +++ b/PolyChat/Models/NetworkingController.cs @@ -0,0 +1,103 @@ +using System; +using System.Collections.Generic; +using SocketIOSharp.Client; +using EngineIOSharp.Common.Enum; +using System.Net; + +namespace PolyChat.Models +{ + class NetworkingController + { + public List clients = new List(); + private String ownName = ""; + private IPAddress ownIP; + MainPage uiController; + + public NetworkingController (MainPage uiController) + { + this.uiController = uiController; + this.ownIP = getIP(); + } + + //EXTERNAL METHODS + //================================================================================= + + /// + /// connects self to server with given ip + /// + /// server to connect to + public void connectNewClient(String ip) + { + SocketIOClient connection = new SocketIOClient(new SocketIOClientOption(EngineIOScheme.http, ip, 8050)); + connection.Connect(); + clients.Add(new Client(connection, ip)); + } + + /// + /// sends Message to given ip + /// + /// partner to send to + /// to send + public void sendMessage(String ip, String msg) + { + this.getClient(ip).sendMessage(SendCode.Message, msg); + } + + /// + /// changes name of self and sends new name to all chats + /// + /// + public void changeName(String newName) + { + this.ownName = newName; + foreach(Client cl in clients) + { + cl.sendNameChange(SendCode.NameChange, newName); + } + } + + //================================================================================= + //INTERNAL METHODS + //================================================================================= + + /// + /// returns client that fits to ip adress + /// + /// + /// + private Client getClient(String ip) + { + foreach (Client cl in clients) + { + if (cl.getIP().Equals(ip)) + { + return cl; + } + } + return null; + } + + private IPAddress getIP() + { + IPHostEntry ipEntry = Dns.GetHostEntry(Dns.GetHostName()); + IPAddress[] addrList = ipEntry.AddressList; + + for (short i = 0; i < addrList.Length; i++) + { + if (addrList[i].ToString().Substring(0, 3).Equals("10.")) + { + return addrList[i]; + //get ip as byte array + /* + byte[] ba = System.Text.Encoding.ASCII.GetBytes(addrList[i].ToString()); + foreach (var item in ba) + { + Console.Write(item.ToString() + ","); + } + */ + } + } + return null; + } + } +} diff --git a/PolyChat/Models/SendCode.cs b/PolyChat/Models/SendCode.cs index 0fd4f78..0995534 100644 --- a/PolyChat/Models/SendCode.cs +++ b/PolyChat/Models/SendCode.cs @@ -4,7 +4,7 @@ { Message, Command, - test1, - test2 + NameChange, + Initial } } \ No newline at end of file diff --git a/PolyChat/Models/Socket.cs b/PolyChat/Models/Socket.cs index 8dcec3c..5107ad6 100644 --- a/PolyChat/Models/Socket.cs +++ b/PolyChat/Models/Socket.cs @@ -14,7 +14,7 @@ namespace PolyChat.Models { private Controller p; private readonly ushort Port; - private SocketIOServer Server; + private SocketIOServer server; private List Sockets = new List(); /// @@ -25,9 +25,9 @@ namespace PolyChat.Models { this.Port = Port; this.p = p; - Server = new SocketIOServer(new SocketIOServerOption(Port)); - Server.OnConnection((socket) => OnConnect(socket)); - Server.Start(); + server = new SocketIOServer(new SocketIOServerOption(Port)); + server.OnConnection((socket) => OnConnect(socket)); + server.Start(); Console.WriteLine($"Server started, binding to port {Port}, waiting for connection..."); } diff --git a/PolyChat/PolyChat.csproj b/PolyChat/PolyChat.csproj index 1393077..d4c68d8 100644 --- a/PolyChat/PolyChat.csproj +++ b/PolyChat/PolyChat.csproj @@ -124,6 +124,7 @@ + From 8097b9f2cf6d615e4a6e1b3341ac7235eb8bbca2 Mon Sep 17 00:00:00 2001 From: SCM6WE Date: Tue, 21 Sep 2021 10:56:54 +0200 Subject: [PATCH 5/5] exception when message cannot be send --- PolyChat/Models/ChatMessage.cs | 2 - PolyChat/Models/Client.cs | 18 ++++++- .../Exceptions/MessageTimedOutException.cs | 16 ++++++ PolyChat/Models/NetworkingController.cs | 53 +++++++++---------- PolyChat/PolyChat.csproj | 1 + 5 files changed, 59 insertions(+), 31 deletions(-) create mode 100644 PolyChat/Models/Exceptions/MessageTimedOutException.cs diff --git a/PolyChat/Models/ChatMessage.cs b/PolyChat/Models/ChatMessage.cs index 96ad8ff..60cb6d0 100644 --- a/PolyChat/Models/ChatMessage.cs +++ b/PolyChat/Models/ChatMessage.cs @@ -21,8 +21,6 @@ namespace PolyChat.Models this.Ip = Ip; } - - override public string ToString() { diff --git a/PolyChat/Models/Client.cs b/PolyChat/Models/Client.cs index e2df56e..748965f 100644 --- a/PolyChat/Models/Client.cs +++ b/PolyChat/Models/Client.cs @@ -12,6 +12,7 @@ using Json.Net; using System.Net; using SocketIOSharp.Common.Packet; using System.Threading; +using PolyChat.Models.Exceptions; namespace PolyChat.Models { @@ -49,11 +50,22 @@ namespace PolyChat.Models //convert msg String petJson = JsonNet.Serialize(msg); - //send msg + //wait if not connected and send msg + int i=0; + int sleeptimer = 2000; + while(!this.connected) + { + Thread.Sleep(sleeptimer); + i++; + if(i>=10) + { + throw new MessageTimedOutException(i*sleeptimer); + } + } connection.Emit(code.ToString(), petJson); }).Start(); } - + /* /// /// Sends Message with new name /// @@ -74,6 +86,7 @@ namespace PolyChat.Models connection.Emit(code.ToString(), petJson); }).Start(); } + */ //================================================================================== //EventHandeling @@ -91,6 +104,7 @@ namespace PolyChat.Models ChatMessage pet = JsonNet.Deserialize(BitConverter.ToString(Data[0].ToObject())); //TODO: send message to GUI }); + connection.On(SendCode.Command.ToString(), (Data) => { Console.WriteLine("Command recieved!" + Data[0]); diff --git a/PolyChat/Models/Exceptions/MessageTimedOutException.cs b/PolyChat/Models/Exceptions/MessageTimedOutException.cs new file mode 100644 index 0000000..77e7355 --- /dev/null +++ b/PolyChat/Models/Exceptions/MessageTimedOutException.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PolyChat.Models.Exceptions +{ + public class MessageTimedOutException : Exception + { + public MessageTimedOutException(int seconds) : base(String.Format("After {0} seconds of trying to send the message it has timed out", seconds)) + { + + } + } +} diff --git a/PolyChat/Models/NetworkingController.cs b/PolyChat/Models/NetworkingController.cs index 90183ba..0b09d2f 100644 --- a/PolyChat/Models/NetworkingController.cs +++ b/PolyChat/Models/NetworkingController.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using SocketIOSharp.Client; using EngineIOSharp.Common.Enum; using System.Net; +using PolyChat.Models.Exceptions; namespace PolyChat.Models { @@ -20,7 +21,7 @@ namespace PolyChat.Models } //EXTERNAL METHODS - //================================================================================= + //========================================================================================================================================================================================= /// /// connects self to server with given ip @@ -43,6 +44,26 @@ namespace PolyChat.Models this.getClient(ip).sendMessage(SendCode.Message, msg); } + /// + /// returns own ip adress + /// + /// + public IPAddress getIP() + { + IPHostEntry ipEntry = Dns.GetHostEntry(Dns.GetHostName()); + IPAddress[] addrList = ipEntry.AddressList; + + for (short i = 0; i < addrList.Length; i++) + { + if (addrList[i].ToString().Substring(0, 3).Equals("10.")) + { + return addrList[i]; + } + } + return null; + } + + /* /// /// changes name of self and sends new name to all chats /// @@ -55,11 +76,12 @@ namespace PolyChat.Models cl.sendNameChange(SendCode.NameChange, newName); } } + */ - //================================================================================= + //========================================================================================================================================================================================= //INTERNAL METHODS - //================================================================================= - + //========================================================================================================================================================================================= + /// /// returns client that fits to ip adress /// @@ -76,28 +98,5 @@ namespace PolyChat.Models } return null; } - - private IPAddress getIP() - { - IPHostEntry ipEntry = Dns.GetHostEntry(Dns.GetHostName()); - IPAddress[] addrList = ipEntry.AddressList; - - for (short i = 0; i < addrList.Length; i++) - { - if (addrList[i].ToString().Substring(0, 3).Equals("10.")) - { - return addrList[i]; - //get ip as byte array - /* - byte[] ba = System.Text.Encoding.ASCII.GetBytes(addrList[i].ToString()); - foreach (var item in ba) - { - Console.Write(item.ToString() + ","); - } - */ - } - } - return null; - } } } diff --git a/PolyChat/PolyChat.csproj b/PolyChat/PolyChat.csproj index d4c68d8..851d98e 100644 --- a/PolyChat/PolyChat.csproj +++ b/PolyChat/PolyChat.csproj @@ -124,6 +124,7 @@ +