public void AddChat(User user, string chatMsg) { ChatInfo chatInfo = new ChatInfo(); chatInfo.Chat = chatMsg; chatInfo.Name = user.Name; NetworkMessage message = new NetworkMessage(); message.MessageCategory = SystemMessages.SystemPrefix; message.MessageType = SystemMessages.SendChat; message.MessageContent = NetworkSerializer.Serialize(chatInfo); lock (this.serverLock) { Chat chat = new Chat(user, chatMsg, DateTime.Now); user.Lobby.Chats.Add(chat); foreach (User u in user.Lobby.Users) { u.Connection.SendMessage(message); } } }
public void SendChat(string chat) { ChatInfo chatInfo = new ChatInfo(); chatInfo.Chat = chat; chatInfo.Name = this.username; NetworkMessage message = new NetworkMessage(); message.MessageCategory = SystemMessages.SystemPrefix; message.MessageType = SystemMessages.SendChat; message.MessageContent = NetworkSerializer.Serialize(chatInfo); this.SendSystemMessage(message); }