Пример #1
0
        /// <summary>
        /// The class constructor that initialize the game values.
        /// </summary>
        /// <param name="idGame"> Game identifier to which the user is in. </param>
        /// <param name="username"> The username of the user logged in sesion. </param>
        /// <param name="isHost"> A Boolean value that determines if the user is the owner of the game. </param>
        public GameWindow(int idGame, string username, bool isHost)
        {
            InitializeComponent();
            this.GameId   = idGame;
            this.username = username;
            this.isHost   = isHost;

            context    = new InstanceContext(this);
            serverChat = new Proxy.ChatServiceClient(context);
            serverChat.JoinChat(idGame, this.username);
            serverGame = new Proxy.GameServiceClient(context);

            serverGame.JoinCurrentGame(idGame, this.username);

            serverGame.GetPlayersName(GameId);

            serverGame.GetFirstSevenTiles(idGame);
        }
Пример #2
0
        private void ClickValidate(object sender, EventArgs e)
        {
            string token = TextBoxToken.Text;

            if (!string.IsNullOrEmpty(token))
            {
                try
                {
                    Proxy.LoginServiceClient verificator = new Proxy.LoginServiceClient();
                    bool isVerified = verificator.VerificateUser(username, token);
                    verificator.Close();

                    if (isVerified)
                    {
                        ButtonChat.IsEnabled           = true;
                        TextBoxChat.IsEnabled          = true;
                        ButtonSeeScores.IsEnabled      = true;
                        ButtonChangePassword.IsEnabled = true;
                        ButtonPlay.IsEnabled           = true;

                        TextBoxToken.Visibility   = Visibility.Collapsed;
                        IconToken.Visibility      = Visibility.Collapsed;
                        ButtonValidate.Visibility = Visibility.Collapsed;
                        LabelAlert.Content        = Properties.Resources.AccountHasBeenVerifiedText;

                        server.JoinChat(0, username);
                    }
                    else
                    {
                        MessageBox.Show(Properties.Resources.UnsuccessfulVerification);
                    }
                }
                catch (System.ServiceModel.EndpointNotFoundException ex)
                {
                    Console.WriteLine(ex.ToString());
                    LabelAlert.Content = Properties.Resources.ServerIsOff;
                }
            }
            else
            {
                MessageBox.Show(Properties.Resources.EmptyFields);
            }
        }
Пример #3
0
        /// <summary>
        /// The class constructor initializes the menu and verifies that the user is registered.
        /// </summary>
        /// <param name="username"> The user in logged in session. </param>
        public MenuWindow(string username)
        {
            InitializeComponent();
            content       = Content;
            this.username = username;

            context = new InstanceContext(this);
            server  = new Proxy.ChatServiceClient(context);
            Proxy.LoginServiceClient verificator = new Proxy.LoginServiceClient();

            if (verificator.IsVerified(username))
            {
                server.JoinChat(0, username);
            }
            else
            {
                UserNotVerified();
            }

            verificator.Close();
        }