/// <summary> /// Check all process files mod dates, to see if recent /// </summary> private void CheckLiveProcessFiles() { var deadGames = new List <GameSession>(); foreach (var gameSession in _map.GetAllGameSessions()) { string heartbeatFile = gameSession.ProcessStatusFilepath; var status = GetStatusFromHeartbeatFileTime(gameSession); if (status == ServerAccountStatusEnum.None) { Logger.WriteDebug("Found dead game: {0}", gameSession.Description); deadGames.Add(gameSession); } else { // Handle orphan games that never got a heartbeat if (status == ServerAccountStatusEnum.Warning && gameSession.LastGoodStatusUtc == DateTime.MinValue) { status = ServerAccountStatusEnum.None; } if (gameSession.Status != status) { Logger.WriteDebug("Found orphan game {0}, changing status from {1} to {2}", gameSession.Description, gameSession.Status, status); gameSession.Status = status; NotifyGameChange(gameSession, GameChangeType.ChangeStatus); } } } foreach (var deadGame in deadGames) { deadGame.Status = ServerAccountStatusEnum.None; Logger.WriteDebug("Removing dead game: {0}", deadGame.Description); RemoveSessionByPidKey(deadGame.ProcessIdKey); } }
private void HandleBroadcastCommand(GameSession inboundGameSession, string commandString) { if (string.IsNullOrWhiteSpace(commandString)) { return; } List <string> teamNames = FindTeamsSpecified(ref commandString); if (string.IsNullOrEmpty(commandString)) { return; } foreach (var gameSession in _gameSessionMap.GetAllGameSessions()) { if (gameSession.GameChannel == null) { continue; } if (teamNames == null || gameSession.HasAnyTeam(teamNames)) { Logger.WriteInfo(string.Format( "Sending command '{0}' to {1}", commandString, gameSession.Description )); SendGameCommand(gameSession, commandString); } } }