private void EnterSubstate(OnlineSubstate nextSubstate)
        {
            switch (nextSubstate)
            {
            case OnlineSubstate.OnlineMenu:
                var onlineMenu = new OnlineMenu();
                Program.MainWindow.SwitchScreen(onlineMenu);
                break;

            case OnlineSubstate.OnlineBoard:
                var board = new OnlineBoardPanel();
                Program.MainWindow.SwitchScreen(board);
                break;

            case OnlineSubstate.GameCreation:
                var campaignConfig = new OnlineGameConfig();
                campaignConfig.InitConfig();
                campaignConfig.GotoConfigWindows();
                break;

            case OnlineSubstate.WaitingRoom:
                var waitingRoom = new WaitingRoom();
                Program.MainWindow.SwitchScreen(waitingRoom);
                break;
            }
            _currentSubState = nextSubstate;
        }
        private void HandleOnlineSessionEvent(AbstractSessionEvent sessionEvent)
        {
            var terminateEvent = sessionEvent as TerminateSessionEvent;

            if (terminateEvent != null)
            {
                TerminateSessionEvent.ExplainCauseToUser(terminateEvent.Cause);
                if (IsGameRunning())
                {
                    EndGame(EndGameType.Disconnect);
                }
                ExitGame();
                EnterSubstate(OnlineSubstate.OnlineBoard);
            }

            var kickPlayerEvent = sessionEvent as KickPlayerEvent;

            if (kickPlayerEvent != null)
            {
                if (kickPlayerEvent.KickedPlayerId == Profile.Instance.CurrentProfile.UserHashId)
                {
                    MessageHelper.ShowMessage("Vous avez mal à votre popotin!", "Le puissant serviteur de la reine du bal vous à expulsé du bal à coup de pied sur les fesses!");
                    ExitGame();
                    EnterSubstate(OnlineSubstate.OnlineBoard);
                }
            }

            var playerReadyEvent = sessionEvent as PlayerReadyEvent;

            if (playerReadyEvent != null)
            {
            }

            var startOnlineGame = sessionEvent as StartGameEvent;

            if (startOnlineGame != null)
            {
                _currentGame.Start(false);
                _currentSubState = OnlineSubstate.InGame;
            }

            var endOnlineGame = sessionEvent as EndOnlineGameEvent;

            if (endOnlineGame != null)
            {
                Console.WriteLine("**************** Received EndOnlineGameEvent ****************");
                EndOnlineGameEvent.ExplainCauseToUser(endOnlineGame.EndCause);
                EndGame(endOnlineGame.EndCause);
                ExitGame();
                EnterSubstate(OnlineSubstate.OnlineBoard);
            }

            var playerForfeit = sessionEvent as PlayerForfeitEvent;

            if (playerForfeit != null)
            {
                Console.WriteLine("**************** A player had forfeit ****************");
            }
        }
        /// <summary>
        ///  Will go the waiting room if the game is not started or in the game if the game is started
        /// </summary>
        /// <param name="gameId"></param>
        void JoinSession(string gameId)
        {
            var model = GameAccess.Instance.GetGameInfo(gameId);

            JoinWaitingRoom(model.HashId, model.HostHashId == Profile.Instance.CurrentProfile.UserHashId);
            if (model.State == EnumsModel.GameState.Started)
            {
                _currentGame.Start(true);
                _currentSubState = OnlineSubstate.InGame;
            }
        }