Пример #1
0
        private void ButtonJoinClick(object sender, RoutedEventArgs e)
        {
            if (WindowManager.PreGameLobbyWindow != null || WindowManager.PlayWindow != null)
            {
                MessageBox.Show(
                    "You are currently in a game or game lobby. Please leave before you join game.",
                    "OCTGN",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
                return;
            }
            var client = new Octgn.Site.Api.ApiClient();

            if (!client.IsGameServerRunning(Program.LobbyClient.Username, Program.LobbyClient.Password))
            {
                TopMostMessageBox.Show("The game server is currently down. Please try again later.", "Error", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }
            var hostedgame = ListViewGameList.SelectedItem as HostedGameViewModel;

            if (hostedgame == null)
            {
                return;
            }
            var game = GameManager.Get().GetById(hostedgame.GameId);
            var task = new Task(() => this.StartJoinGame(hostedgame, game));

            task.ContinueWith((t) => { this.Dispatcher.Invoke(new Action(() => this.FinishJoinGame(t))); });
            BorderButtons.IsEnabled = false;
            task.Start();
        }
Пример #2
0
        async Task StartOnlineGame(DataNew.Entities.Game game, string name, string password)
        {
            var client = new Octgn.Site.Api.ApiClient();

            if (!client.IsGameServerRunning(Program.LobbyClient.Username, Program.LobbyClient.Password))
            {
                throw new UserMessageException("The game server is currently down. Please try again later.");
            }
            Program.CurrentOnlineGameName = name;
            // TODO: Replace this with a server-side check
            password = SubscriptionModule.Get().IsSubscribed == true ? password : String.Empty;
            var result = await Program.LobbyClient.HostGame(game, name, password, game.Name, game.IconUrl,
                                                            typeof(Octgn.Server.Server).Assembly.GetName().Version, Specators);

            if (result == null)
            {
                throw new InvalidOperationException("HostGame returned a null");
            }

            Program.LobbyClient.CurrentHostedGamePort = (int)result.Port;
            //Program.GameSettings.UseTwoSidedTable = true;
            Program.GameEngine = new GameEngine(game, Program.LobbyClient.Me.UserName, false, this.Password);
            Program.IsHost     = true;

            var hostAddress = Dns.GetHostAddresses(AppConfig.GameServerPath).First();

            // Should use gameData.IpAddress sometime.
            Program.Client = new ClientSocket(hostAddress, (int)result.Port);
            Program.Client.Connect();
            SuccessfulHost = true;
        }
Пример #3
0
        private void StartJoinGame(HostedGameViewModel hostedGame, DataNew.Entities.Game game)
        {
            var client = new Octgn.Site.Api.ApiClient();

            if (!client.IsGameServerRunning(Program.LobbyClient.Username, Program.LobbyClient.Password))
            {
                throw new UserMessageException("The game server is currently down. Please try again later.");
            }
            Log.InfoFormat("Starting to join a game {0} {1}", hostedGame.GameId, hostedGame.Name);
            Program.IsHost                = false;
            Program.GameEngine            = new GameEngine(game, Program.LobbyClient.Me.UserName);
            Program.CurrentOnlineGameName = hostedGame.Name;
            IPAddress hostAddress = Dns.GetHostAddresses(AppConfig.GameServerPath).FirstOrDefault();

            if (hostAddress == null)
            {
                Log.WarnFormat("Dns Error, couldn't resolve {0}", AppConfig.GameServerPath);
                throw new UserMessageException("There was a problem with your DNS. Please try again.");
            }

            try
            {
                Log.InfoFormat("Creating client for {0}:{1}", hostAddress, hostedGame.Port);
                Program.Client = new Client(hostAddress, hostedGame.Port);
                Log.InfoFormat("Connecting client for {0}:{1}", hostAddress, hostedGame.Port);
                Program.Client.Connect();
            }
            catch (Exception e)
            {
                Log.Warn("Start join game error ", e);
                throw new UserMessageException("Could not connect. Please try again.");
            }
        }
Пример #4
0
        private void RefreshApiTimerOnElapsed(object sender, ElapsedEventArgs elapsedEventArgs)
        {
            if (runningTimer)
            {
                return;
            }
            runningTimer = true;
            Log.Info("Refreshing User Manager");
            var unlist = new string[0];

            lock (UserCacheLocker) unlist = UserCache.Keys.Select(x => x.UserName).ToArray();

            var users = new Octgn.Site.Api.ApiClient().UsersFromUsername(unlist);

            if (users == null)
            {
                Log.Warn("User Manager Refresh failed");
                runningTimer = false;
                return;
            }

            lock (UserCacheLocker)
            {
                foreach (var u in UserCache.ToDictionary(x => x.Key, x => x.Value))
                {
                    var apiuser =
                        users.FirstOrDefault(
                            x => x.UserName.Equals(u.Key.UserName, StringComparison.InvariantCultureIgnoreCase));
                    UserCache[u.Key] = apiuser;
                }
            }
            runningTimer = false;
            this.FireOnUpdate();
        }
Пример #5
0
        public override void OnClick()
        {
            if (HostedGame.Source == HostedGameSource.Online)
            {
                var client = new Octgn.Site.Api.ApiClient();
                if (!client.IsGameServerRunning(Program.LobbyClient.Username, Program.LobbyClient.Password))
                {
                    throw new UserMessageException("The game server is currently down. Please try again later.");
                }
            }
            Log.InfoFormat("Starting to join a game {0} {1}", HostedGame.GameGuid, HostedGame.Name);
            Program.IsHost        = false;
            Program.IsMatchmaking = false;
            var username = (Program.LobbyClient.IsConnected == false ||
                            Program.LobbyClient.Me == null ||
                            Program.LobbyClient.Me.UserName == null) ? Prefs.Nickname : Program.LobbyClient.Me.UserName;

            if (HostedGame.GameStatus == EHostedGame.GameInProgress && HostedGame.Spectator == false)
            {
                throw new UserMessageException("Cannot join game, it does not allow spectators.");
            }

            bool spectator = HostedGame.GameStatus == EHostedGame.GameInProgress && HostedGame.Spectator;

            Program.GameEngine            = new GameEngine(Game, username, spectator, Invite.Password);
            Program.CurrentOnlineGameName = HostedGame.Name;
            IPAddress hostAddress = HostedGame.IpAddress;

            if (hostAddress == null)
            {
                Log.WarnFormat("Dns Error, couldn't resolve {0}", AppConfig.GameServerPath);
                throw new UserMessageException("There was a problem with your DNS. Please try again.");
            }

            try
            {
                Log.InfoFormat("Creating client for {0}:{1}", hostAddress, HostedGame.Port);
                Program.Client = new ClientSocket(hostAddress, HostedGame.Port);
                Log.InfoFormat("Connecting client for {0}:{1}", hostAddress, HostedGame.Port);
                Program.Client.Connect();
                WindowManager.GrowlWindow.Dispatcher.Invoke(new Action(() =>
                {
                    WindowManager.PlayWindow = new PlayWindow();
                    WindowManager.PlayWindow.Show();
                    //WindowManager.PreGameLobbyWindow = new PreGameLobbyWindow();
                    //WindowManager.PreGameLobbyWindow.Setup(false, WindowManager.Main);
                }));
            }
            catch (Exception e)
            {
                Log.Warn("Start join game error ", e);
                throw new UserMessageException("Could not connect. Please try again.");
            }
        }
Пример #6
0
        void StartOnlineGame(DataNew.Entities.Game game, string name, string password)
        {
            var client = new Octgn.Site.Api.ApiClient();

            if (!client.IsGameServerRunning(Program.LobbyClient.Username, Program.LobbyClient.Password))
            {
                throw new UserMessageException("The game server is currently down. Please try again later.");
            }
            Program.CurrentOnlineGameName = name;
            Program.LobbyClient.BeginHostGame(game, name, password, game.Name);
        }
Пример #7
0
        async Task StartOnlineGame(DataNew.Entities.Game game, string name, string password)
        {
            var client = new Octgn.Site.Api.ApiClient();

            if (!await client.IsGameServerRunning(Prefs.Username, Prefs.Password.Decrypt()))
            {
                throw new UserMessageException("The game server is currently down. Please try again later.");
            }
            Program.CurrentOnlineGameName = name;
            // TODO: Replace this with a server-side check
            password = SubscriptionModule.Get().IsSubscribed == true ? password : String.Empty;

            var octgnVersion = typeof(Server.Server).Assembly.GetName().Version;

            var req = new HostedGame {
                GameId       = game.Id,
                GameVersion  = game.Version.ToString(),
                Name         = name,
                GameName     = game.Name,
                GameIconUrl  = game.IconUrl,
                Password     = password,
                HasPassword  = !string.IsNullOrWhiteSpace(password),
                OctgnVersion = octgnVersion.ToString(),
                Spectators   = Specators
            };

            var result = await Program.LobbyClient.HostGame(req);

            Program.CurrentHostedGame = result ?? throw new InvalidOperationException("HostGame returned a null");
            Program.GameEngine        = new GameEngine(game, Program.LobbyClient.Me.DisplayName, false, this.Password);
            Program.IsHost            = true;

            foreach (var address in Dns.GetHostAddresses(AppConfig.GameServerPath))
            {
                try {
                    if (address == IPAddress.IPv6Loopback)
                    {
                        continue;
                    }

                    // Should use gameData.IpAddress sometime.
                    Log.Info($"{nameof(StartOnlineGame)}: Trying to connect to {address}:{result.Port}");

                    Program.Client = new ClientSocket(address, result.Port);
                    await Program.Client.Connect();

                    SuccessfulHost = true;
                    return;
                } catch (Exception ex) {
                    Log.Error($"{nameof(StartOnlineGame)}: Couldn't connect to address {address}:{result.Port}", ex);
                }
            }
            throw new InvalidOperationException($"Unable to connect to {AppConfig.GameServerPath}.{result.Port}");
        }
Пример #8
0
        private void GameListItemDoubleClick(object sender, MouseButtonEventArgs e)
        {
            if (WindowManager.PlayWindow != null)
            {
                MessageBox.Show(
                    "You are currently in a game or game lobby. Please leave before you join game.",
                    "OCTGN",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
                return;
            }
            var hostedgame = ListViewGameList.SelectedItem as HostedGameViewModel;

            if (hostedgame == null)
            {
                return;
            }
            if (hostedgame.Status == EHostedGame.GameInProgress && hostedgame.Spectator == false)
            {
                TopMostMessageBox.Show(
                    "You can't join a game in progress.",
                    "Error",
                    MessageBoxButton.OK,
                    MessageBoxImage.Information);
                return;
            }
            if (hostedgame.Data.Source == HostedGameSource.Online)
            {
                var client = new Octgn.Site.Api.ApiClient();
                if (!client.IsGameServerRunning(Program.LobbyClient.Username, Program.LobbyClient.Password))
                {
                    TopMostMessageBox.Show(
                        "The game server is currently down. Please try again later.",
                        "Error",
                        MessageBoxButton.OK,
                        MessageBoxImage.Information);
                    return;
                }
            }
            var game = GameManager.Get().GetById(hostedgame.GameId);

            if (game == null)
            {
                TopMostMessageBox.Show("You don't currently have that game installed.", "Error", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }
            bool spectate = hostedgame.Status == EHostedGame.GameInProgress && hostedgame.Spectator;
            var  task     = new Task(() => this.StartJoinGame(hostedgame, game, spectate));

            task.ContinueWith((t) => { this.Dispatcher.Invoke(new Action(() => this.FinishJoinGame(t))); });
            BorderButtons.IsEnabled = false;
            task.Start();
        }
Пример #9
0
        public async Task Start(CancellationToken cancellationToken = default(CancellationToken))
        {
            Log.Info($"{nameof(Start)}: CreateSession");
            var client = new Octgn.Site.Api.ApiClient();
            var result = await client.CreateSession(AppConfig.Instance.ComUsername, AppConfig.Instance.ComPassword, AppConfig.Instance.ComDeviceId);

            _clientAuthenticator.SessionKey = result.SessionKey;
            _clientAuthenticator.UserId     = result.UserId;
            _clientAuthenticator.DeviceId   = AppConfig.Instance.ComDeviceId;

            Log.Info($"{nameof(Start)}: Connect");
            await _chatClient.Connect(cancellationToken);
        }
Пример #10
0
        private void StartJoinGame(HostedGameViewModel hostedGame, DataNew.Entities.Game game, bool spectate)
        {
            if (hostedGame.Data.Source == HostedGameSource.Online)
            {
                var client = new Octgn.Site.Api.ApiClient();
                if (!client.IsGameServerRunning(Program.LobbyClient.Username, Program.LobbyClient.Password))
                {
                    throw new UserMessageException("The game server is currently down. Please try again later.");
                }
            }
            Log.InfoFormat("Starting to join a game {0} {1}", hostedGame.GameId, hostedGame.Name);
            Program.IsHost        = false;
            Program.IsMatchmaking = false;
            var password = "";

            if (hostedGame.HasPassword)
            {
                Dispatcher.Invoke(new Action(() =>
                {
                    var dlg  = new InputDlg("Password", "Please enter this games password", "");
                    password = dlg.GetString();
                }));
            }
            var username = (Program.LobbyClient.IsConnected == false ||
                            Program.LobbyClient.Me == null ||
                            Program.LobbyClient.Me.UserName == null) ? Prefs.Nickname : Program.LobbyClient.Me.UserName;

            Program.GameEngine            = new GameEngine(game, username, spectate, password);
            Program.CurrentOnlineGameName = hostedGame.Name;
            IPAddress hostAddress = hostedGame.IPAddress;

            if (hostAddress == null)
            {
                Log.WarnFormat("Dns Error, couldn't resolve {0}", AppConfig.GameServerPath);
                throw new UserMessageException("There was a problem with your DNS. Please try again.");
            }

            try
            {
                Log.InfoFormat("Creating client for {0}:{1}", hostAddress, hostedGame.Port);
                Program.Client = new ClientSocket(hostAddress, hostedGame.Port);
                Log.InfoFormat("Connecting client for {0}:{1}", hostAddress, hostedGame.Port);
                Program.Client.Connect();
            }
            catch (Exception e)
            {
                Log.Warn("Start join game error ", e);
                throw new UserMessageException("Could not connect. Please try again.");
            }
        }
Пример #11
0
        void StartOnlineGame(DataNew.Entities.Game game, string name, string password)
        {
            var client = new Octgn.Site.Api.ApiClient();

            if (!client.IsGameServerRunning(Program.LobbyClient.Username, Program.LobbyClient.Password))
            {
                throw new UserMessageException("The game server is currently down. Please try again later.");
            }
            Program.CurrentOnlineGameName = name;
            // TODO: Replace this with a server-side check
            password = SubscriptionModule.Get().IsSubscribed == true ? password : String.Empty;
            Program.LobbyClient.BeginHostGame(game, name, password, game.Name,
                                              typeof(Octgn.Server.Server).Assembly.GetName().Version, Specators);
        }
Пример #12
0
        async Task <bool> StartOnlineGame(DataNew.Entities.Game game, string name, string password)
        {
            var client = new Octgn.Site.Api.ApiClient();

            if (!await client.IsGameServerRunning(Prefs.Username, Prefs.Password.Decrypt()))
            {
                throw new UserMessageException("The game server is currently down. Please try again later.");
            }
            Program.CurrentOnlineGameName = name;
            // TODO: Replace this with a server-side check
            password = SubscriptionModule.Get().IsSubscribed == true ? password : String.Empty;

            var octgnVersion = typeof(Server.Server).Assembly.GetName().Version;

            var req = new HostedGame {
                GameId       = game.Id,
                GameVersion  = game.Version.ToString(),
                Name         = name,
                GameName     = game.Name,
                GameIconUrl  = game.IconUrl,
                Password     = password,
                HasPassword  = !string.IsNullOrWhiteSpace(password),
                OctgnVersion = octgnVersion.ToString(),
                Spectators   = Specators
            };

            var lobbyClient = Program.LobbyClient ?? throw new InvalidOperationException("lobby client null");

            HostedGame result = null;

            try {
                result = await lobbyClient.HostGame(req);
            } catch (ErrorResponseException ex) {
                if (ex.Code != ErrorResponseCodes.UserOffline)
                {
                    throw;
                }
                throw new UserMessageException("The Game Service is currently offline. Please try again.");
            }

            var launchedEngine = await Program.JodsEngine.HostGame(
                result,
                HostedGameSource.Online,
                lobbyClient.User.DisplayName,
                Password
                );

            return(launchedEngine);
        }
Пример #13
0
        public async Task Start(CancellationToken cancellationToken = default(CancellationToken))
        {
            Log.Info($"{nameof(Start)}: CreateSession");
            var client = new Octgn.Site.Api.ApiClient();
            var result = await client.CreateSession(AppConfig.Instance.ComUsername, AppConfig.Instance.ComPassword, AppConfig.Instance.ComDeviceId);

            if (result.Result.Type != Site.Api.LoginResultType.Ok)
            {
                throw new InvalidOperationException($"Couldn't not start. Error creating session: {result.Result.Type}");
            }

            _clientAuthenticator.SessionKey = result.SessionKey;
            _clientAuthenticator.UserId     = result.UserId;
            _clientAuthenticator.DeviceId   = AppConfig.Instance.ComDeviceId;

            Log.Info($"{nameof(Start)}: Connect");
            await _chatClient.Connect(cancellationToken);
        }
Пример #14
0
 public UpdateDetails UpdateInfo()
 {
     lock (this)
     {
         Version            = null;
         InstallUrl         = null;
         this.LastCheckTime = DateTime.Now;
         IsFaulted          = true;
         var url = AppConfig.UpdateInfoPath;
         try
         {
             var c    = new Octgn.Site.Api.ApiClient();
             var info = c.GetLatestRelease(_currentVerison);
             if (Program.IsReleaseTest == false)
             {
                 Version         = Version.Parse(info.LiveVersion);
                 this.InstallUrl = info.LiveVersionDownloadLocation;
             }
             else
             {
                 Version         = Version.Parse(info.TestVersion);
                 this.InstallUrl = info.TestVersionDownloadLocation;
             }
             if (!String.IsNullOrWhiteSpace(InstallUrl) && Version != null)
             {
                 IsFaulted = false;
             }
         }
         catch (WebException e)
         {
             Log.Warn("", e);
             IsFaulted = true;
         }
         catch (Exception e)
         {
             Log.Warn("", e);
             IsFaulted = true;
         }
         return(this);
     }
 }
Пример #15
0
 void StartOnlineGame(DataNew.Entities.Game game, string name, string password)
 {
     var client = new Octgn.Site.Api.ApiClient();
     if (!client.IsGameServerRunning(Program.LobbyClient.Username, Program.LobbyClient.Password))
     {
         throw new UserMessageException("The game server is currently down. Please try again later.");
     }
     Program.CurrentOnlineGameName = name;
     // TODO: Replace this with a server-side check
     password = SubscriptionModule.Get().IsSubscribed == true ? password : String.Empty;
     Program.LobbyClient.BeginHostGame(game, name, password, game.Name, game.IconUrl, 
         typeof(Octgn.Server.Server).Assembly.GetName().Version,Specators);
 }
Пример #16
0
        private void RefreshApiTimerOnElapsed(object sender, ElapsedEventArgs elapsedEventArgs)
        {
            if (runningTimer) return;
            runningTimer = true;
            if ((int)RefreshApiTimer.Interval == 10000)
                RefreshApiTimer.Interval = TimeSpan.FromMinutes(10).TotalMilliseconds;
            Log.Info("Refreshing User Manager");
            var unlist = new string[0];
            lock (UserCacheLocker) unlist = UserCache.Keys.Select(x => x.UserName).ToArray();

            var users = new Octgn.Site.Api.ApiClient().UsersFromUsername(unlist);
            if (users == null)
            {
                Log.Warn("User Manager Refresh failed");
                runningTimer = false;
                return;
            }

            lock (UserCacheLocker)
            {
                foreach (var u in UserCache.ToDictionary(x=>x.Key,x=>x.Value))
                {
                    var apiuser =
                        users.FirstOrDefault(
                            x => x.UserName.Equals(u.Key.UserName, StringComparison.InvariantCultureIgnoreCase));
                    UserCache[u.Key] = apiuser;
                }
            }
            runningTimer = false;
            this.FireOnUpdate();
        }
Пример #17
0
 public UpdateDetails UpdateInfo()
 {
     lock (this)
     {
         Version = null;
         InstallUrl = null;
         this.LastCheckTime = DateTime.Now;
         IsFaulted = true;
         var url = AppConfig.UpdateInfoPath;
         try
         {
             var c = new Octgn.Site.Api.ApiClient();
             var info = c.GetReleaseInfo();
             if (Program.IsReleaseTest == false)
             {
                 Version = Version.Parse(info.LiveVersion);
                 this.InstallUrl = info.LiveVersionDownloadLocation;
             }
             else
             {
                 Version = Version.Parse(info.TestVersion);
                 this.InstallUrl = info.TestVersionDownloadLocation;
             }
             if (!String.IsNullOrWhiteSpace(InstallUrl) && Version != null)
             {
                 IsFaulted = false;
             }
         }
         catch (WebException e)
         {
             Log.Warn("", e);
             IsFaulted = true;
         }
         catch (Exception e)
         {
             Log.Warn("", e);
             IsFaulted = true;
         }
         return this;
     }
 }
Пример #18
0
 void StartOnlineGame(DataNew.Entities.Game game, string name, string password)
 {
     var client = new Octgn.Site.Api.ApiClient();
     if (!client.IsGameServerRunning(Program.LobbyClient.Username, Program.LobbyClient.Password))
     {
         throw new UserMessageException("The game server is currently down. Please try again later.");
     }
     Program.CurrentOnlineGameName = name;
     Program.LobbyClient.BeginHostGame(game, name);
 }
Пример #19
0
        private void StartJoinGame(HostedGameViewModel hostedGame, DataNew.Entities.Game game)
        {
            var client = new Octgn.Site.Api.ApiClient();
            if (!client.IsGameServerRunning(Program.LobbyClient.Username, Program.LobbyClient.Password))
            {
                throw new UserMessageException("The game server is currently down. Please try again later.");
            }
            Log.InfoFormat("Starting to join a game {0} {1}", hostedGame.GameId, hostedGame.Name);
            Program.IsHost = false;
            var password = "";
            if (hostedGame.HasPassword)
            {
                Dispatcher.Invoke(new Action(() =>
                    {
                        var dlg = new InputDlg("Password", "Please enter this games password", "");
                        password = dlg.GetString();
                    }));
            }
            Program.GameEngine = new GameEngine(game, Program.LobbyClient.Me.UserName,password);
            Program.CurrentOnlineGameName = hostedGame.Name;
            IPAddress hostAddress = Dns.GetHostAddresses(AppConfig.GameServerPath).FirstOrDefault();
            if (hostAddress == null)
            {
                Log.WarnFormat("Dns Error, couldn't resolve {0}", AppConfig.GameServerPath);
                throw new UserMessageException("There was a problem with your DNS. Please try again.");
            }

            try
            {
                Log.InfoFormat("Creating client for {0}:{1}", hostAddress, hostedGame.Port);
                Program.Client = new Client(hostAddress, hostedGame.Port);
                Log.InfoFormat("Connecting client for {0}:{1}", hostAddress, hostedGame.Port);
                Program.Client.Connect();
            }
            catch (Exception e)
            {
                Log.Warn("Start join game error ", e);
                throw new UserMessageException("Could not connect. Please try again.");
            }
        }
Пример #20
0
 private void GameListItemDoubleClick(object sender, MouseButtonEventArgs e)
 {
     if (WindowManager.PreGameLobbyWindow != null || WindowManager.PlayWindow != null)
     {
         MessageBox.Show(
             "You are currently in a game or game lobby. Please leave before you join game.",
             "OCTGN",
             MessageBoxButtons.OK,
             MessageBoxIcon.Error);
         return;
     }
     var client = new Octgn.Site.Api.ApiClient();
     if (!client.IsGameServerRunning(Program.LobbyClient.Username, Program.LobbyClient.Password))
     {
         TopMostMessageBox.Show("The game server is currently down. Please try again later.", "Error", MessageBoxButton.OK, MessageBoxImage.Information);
         return;
     }
     var hostedgame = ListViewGameList.SelectedItem as HostedGameViewModel;
     if (hostedgame == null) return;
     var game = GameManager.Get().GetById(hostedgame.GameId);
     if (game == null)
     {
         TopMostMessageBox.Show("You don't currently have that game installed.", "Error", MessageBoxButton.OK, MessageBoxImage.Information);
         return;
     }
     var task = new Task(() => this.StartJoinGame(hostedgame, game));
     task.ContinueWith((t) => { this.Dispatcher.Invoke(new Action(() => this.FinishJoinGame(t))); });
     BorderButtons.IsEnabled = false;
     task.Start();
 }