/// <summary> /// Handles the LobbyLost AGCEvent /// </summary> /// <param name="sender">The object firing the event</param> /// <param name="e">The arguments of the event</param> public static void LobbyLostAGCEventHandler(object sender, LobbyLostAGCEventArgs e) { try { TagTrace.WriteLine(TraceLevel.Verbose, "LobbyLost event received."); // Send a chat to all games informing that lobby was lost GameServer.SendChat("This server has disconnected from the lobby. New players will be unable to find this game until the server reconnects."); // Log lobby losts to all current games foreach (Game CurrentGame in GameServer.Games) { TagTrace.WriteLine(TraceLevel.Verbose, "LobbyLost Event waiting to lock Game {0}'s GameData...", CurrentGame.GameID); lock (CurrentGame.GetSyncRoot()) { CurrentGame.GameData.LogLobbyLost(e.Time); TagTrace.WriteLine(TraceLevel.Info, "LobbyLost event logged to game {0}.", CurrentGame.GameID); } } } catch (Exception ex) { TagTrace.WriteLine(TraceLevel.Error, "Error handling LobbyLost event: {0}", ex.Message); } }
/// <summary> /// Handles the LobbyDisconnecting AGCEvent /// </summary> /// <param name="sender">The object firing the event</param> /// <param name="e">The arguments of the event</param> public static void LobbyDisconnectingAGCEventHandler(object sender, LobbyDisconnectingAGCEventArgs e) { try { TagTrace.WriteLine(TraceLevel.Verbose, "LobbyDisconnecting event received."); // Log lobby disconnectings to all current games foreach (Game CurrentGame in GameServer.Games) { TagTrace.WriteLine(TraceLevel.Verbose, "LobbyDisconnecting Event waiting to lock Game {0}'s GameData...", CurrentGame.GameID); lock (CurrentGame.GetSyncRoot()) { CurrentGame.GameData.LogLobbyDisconnecting(e.Time, e.LobbyIP); TagTrace.WriteLine(TraceLevel.Info, "LobbyDisconnecting event logged to game {0}.", CurrentGame.GameID); } } } catch (Exception ex) { TagTrace.WriteLine(TraceLevel.Error, "Error handling LobbyDisconnecting event: {0}", ex.Message); } }
/// <summary> /// Handles the LobbyConnected AGCEvent /// </summary> /// <param name="sender">The object firing the event</param> /// <param name="e">The arguments of the event</param> public static void LobbyConnectedAGCEventHandler(object sender, LobbyConnectedAGCEventArgs e) { try { TagTrace.WriteLine(TraceLevel.Verbose, "LobbyConnected event received."); // Inform users that the lobby is (back) up GameServer.SendChat("This server has connected to the Lobby. New players can now join this game."); // Log lobby connects to all current games foreach (Game CurrentGame in GameServer.Games) { TagTrace.WriteLine(TraceLevel.Verbose, "LobbyConnected Event waiting to lock Game {0}'s GameData...", CurrentGame.GameID); lock (CurrentGame.GetSyncRoot()) { CurrentGame.GameData.LogLobbyConnected(e.Time, e.LobbyIP); TagTrace.WriteLine(TraceLevel.Info, "LobbyConnected event logged to game {0}.", CurrentGame.GameID); } } } catch (Exception ex) { TagTrace.WriteLine(TraceLevel.Error, "Error handling LobbyConnected event: {0}", ex.Message); } }