/// <summary> /// Gets called whenever an user disconnects to the server /// </summary> /// <param name="msg">The Telepathy.Message sent by the server.getNextMessage() function</param> static void OnUserDisconnect(Telepathy.Message msg) { Logging.Info("[Server] " + msg.connectionId + " Disconnected"); //Check if the user with the connectionid exists and if so delete him from the database Helpers.User user = Users.Find(x => x.ID == msg.connectionId); if (user == null) { Logging.Warn($"[Server] User with the Id {msg.connectionId} did disconnect but no User object was found for him!"); } else { Logging.Info($"[Server] User {user.Username} did disconnect from the Server!"); Users.Remove(user); } }
static void OnChatReceived(Helpers.TcpChat chat) { Helpers.User sender = (Helpers.User)chat.Data.GetValue("sender"); if (sender == null) { sender = new Helpers.User() { Username = "******" } } ; Logging.Info($"[Message] {sender.Username}: {(string)chat.Data.GetValue("message")}"); if (chatMessages.Count == 18) { chatMessages.RemoveAt(0); } chatMessages.Add($"{sender.Username}: {(string)chat.Data.GetValue("message")}"); chatLogMessages.Add($"[{sender.Username}] [{DateTime.Now.ToString()}] {(string)chat.Data.GetValue("message")}"); chatWindow.text = string.Join("\n", chatMessages); } }