Exemplo n.º 1
0
        private async void Ready()
        {
            IsReady       = true;
            IsPageEnabled = false;

            bool result;

            try
            {
                result = await lobbyServer.CreateLobby(CreateLobbySettings());

                ClientProxyManager.Instance.RegisterLobby(this);
            }
            catch (Exception)
            {
                MessageBox.Show("Connection lost.", "Hanksite", MessageBoxButton.OK);
                Application.Current.Shutdown();
                return;
            }

            IsPageEnabled = true;
            if (!result)
            {
                MessageBox.Show("The given lobby name is already used.", "Hanksite", MessageBoxButton.OK);
                IsReady = false;
                return;
            }

            ConnectedPlayers.Add(new Player()
            {
                Username = ClientProxyManager.Instance.UserName
            });
            NotifyPropertyChanged("ConnectedPlayers");
            NotifyPropertyChanged("IsLobbyFull");
        }