private static void ProcessPlayerCountsPacket(string message) { string[] splitMessage = message.SplitMessage(); var packetData = new PlayerCounts() { Port = int.Parse(splitMessage[0]), IsStarted = int.Parse(splitMessage[1]) != 0, CurrentPlayers = int.Parse(splitMessage[2]), MaximumPlayers = int.Parse(splitMessage[3]) }; UpdateState(packetData); }
private static void UpdateState(PlayerCounts packetData) { Program.State.Servers.AddOrUpdate(packetData.Port, new Server() { Port = packetData.Port, LastHeartBeatUtc = DateTime.UtcNow, IsStarted = packetData.IsStarted, CurrentPlayers = packetData.CurrentPlayers, MaximumPlayers = packetData.MaximumPlayers }, (port, server) => { server.IsStarted = packetData.IsStarted; server.CurrentPlayers = packetData.CurrentPlayers; server.MaximumPlayers = packetData.MaximumPlayers; return(server); }); }