Exemple #1
0
 private void goToGameView(object obj)
 {
     if (LobbyViewModel != null)
     {
         LobbyViewModel.Dispose();
         LobbyViewModel = null;
     }
     Task.Delay(500).ContinueWith(_ =>
     {
         if (GameViewModel != null)
         {
             GameViewModel.Dispose();
             GameViewModel = null;
         }
         GameViewModel = new GameViewModel((string)obj);
         App.Current.Dispatcher.Invoke(delegate
         {
             SubChannels.Remove(_subChannels.SingleOrDefault(i => i.id == (Constants.LOBBY_CHANNEL + Lobbyname)));
             MessageChannel gameChannel = new MessageChannel(Constants.GAME_CHANNEL, true, false);
             if (!SubChannels.Contains(gameChannel))
             {
                 SubChannels.Add(gameChannel);
             }
             ChangeChannel(Constants.GAME_CHANNEL);
         });
         SwitchView = Views.Game;
         IsInGame   = true;
     });
 }
Exemple #2
0
        private void goToLobbyView(object lobbyData)
        {
            IsNotInLobby = false;
            Dictionary <string, string> data = new Dictionary <string, string>((Dictionary <string, string>)lobbyData);

            if (LobbyViewModel != null)
            {
                LobbyViewModel.Dispose();
                LobbyViewModel = null;
            }

            LobbyViewModel = new LobbyViewModel(data["lobbyName"], data["mode"]);
            this.Lobbyname = data["lobbyName"];
            string lobbyChannel = Constants.LOBBY_CHANNEL + this.Lobbyname;

            SwitchView = Views.Lobby;
            Application.Current.Dispatcher.Invoke(delegate
            {
                SubChannels.Add(new MessageChannel(lobbyChannel, true, true));
            });
            ChangeChannel(lobbyChannel);
        }
Exemple #3
0
        private void goToGameListView(object obj)
        {
            if (LobbyViewModel != null)
            {
                LobbyViewModel.Dispose();
                LobbyViewModel = null;
            }
            if (GameViewModel != null)
            {
                GameViewModel.Dispose();
                GameViewModel = null;
            }
            IsInGame = false;
            GamelistViewModel.SubscribeLobbyNotif();
            GamelistViewModel.getLobbies();

            SwitchView   = Views.Gamelist;
            IsNotInLobby = true;
            Application.Current.Dispatcher.Invoke(delegate
            {
                FetchChannels();
            });
        }