public static void TerminateSession() { try { if (_instance != null) { EventManager.Instance.Unsubscribe(Instance.HandleEvent); if (ConnectionHelper.IsConnected) { //if (_instance.IsHost) //{ // EventManager.Instance.Interrupt(new TerminateSessionEvent() // { // Cause = terminationCause // }); //} GameAccess.Instance.QuitGame(Instance.SessionId); } } } catch (Exception e) { Console.WriteLine("Error while terminating session\n{0}", e); } finally { _instance = null; } }
public static void InitializeSession(GameModel model) { Debug.Assert(_instance == null, "The previous OnlineSession must be terminated before creating a new one"); _instance = new OnlineSession(); EventManager.Instance.Subscribe(Instance.HandleEvent); _instance.SessionId = model.HashId; _instance.Password = model.Password; _instance.SessionName = model.Name; _instance.UpdateParticipantsList(model); _instance.IsHost = model.HostHashId == Profile.Instance.CurrentProfile.UserHashId; }