private static void UpdateState(PlayerNames packetData) { Program.State.Servers.AddOrUpdate(packetData.Port, new Server() { Port = packetData.Port, IsStarted = packetData.IsStarted, Players = packetData.Names.Select(name => new Player() { Name = name }).ToList() }, (port, server) => { server.IsStarted = packetData.IsStarted; if (server.Players.Count == 0 || server.CurrentPlayers != packetData.Names.Count) { server.CurrentPlayers = packetData.Names.Count; server.Players = packetData.Names.Select(name => new Player() { Name = name, Score = 0 }).ToList(); } return(server); }); }
private static void ProcessPlayerNamesPacket(string message) { string[] splitMessage = message.SplitMessage(); var packetData = new PlayerNames() { Port = int.Parse(splitMessage[0]), Names = splitMessage.Skip(1).ToList(), }; UpdateState(packetData); }