private void SimulatedGame_SessionEnded(SimulatedGameSession session, SessionEndStatistics e) { _removeQueue.Add(session); // Kill any event handler session.SessionEnded -= SimulatedGame_SessionEnded; // Alert the lobby server the match has ended var packet = new SessionEndedLobbyPacket(session.Session.SessionID, e); LobbyServerNetworkManager.Instance.SendPacket(packet); Logger.Instance.Log(Level.Info, "Session " + session.Session.SessionID + ":" + " Completed a simulation job on this application server."); // Remove from the router table and notify game is over foreach (var user in session.Session.Users) { if (user.Connection != null) { _routingTable.Remove(user.Connection); } else { return; } // Send the packet var userPacket = new SessionEndedLobbyPacket(session.Session.SessionID, e); ClientNetworkManager.Instance.SendPacket(userPacket, user.Connection); } }
protected virtual void OnSessionEnded(SimulatedGameSession session, SessionEndStatistics e) { SessionEndedHandler handler = SessionEnded; if (handler != null) { handler(session, e); } }
/// <summary> /// A function for cleaning up the simulation. /// Used for calculating a winner as well. /// </summary> private void TerminateSession() { //TODO: Implement a solver for finding out the winner of the match effectively // In most cases, this is the last player standing but not always // Let subscribers know this game is finished var result = new SessionEndStatistics(Session.Users[0], _timer.Elapsed.TotalSeconds); OnSessionEnded(this, result); }
public SessionEndedLobbyPacket(uint sessionID, SessionEndStatistics sessionStats) { SessionStatistics = sessionStats; SessionID = sessionID; }