Пример #1
0
        //need to chenge to server to make this work
        private void BackClick(object sender, RoutedEventArgs e)
        {
            MenuWindow menu = new MenuWindow();

            menu.Show();
            this.Close();
        }
        //Uses authenticators log in functions to log a user in using their input name and password
        private void LoginButton_Click(object sender, RoutedEventArgs e)
        {
            string name        = UsernameTextLogin.Text;
            string password    = PasswordBox.Password;
            string val         = "";
            var    tcp         = new NetTcpBinding();
            var    URL         = "net.tcp://localhost:8101/AuthenticationService";
            var    authFactory = new ChannelFactory <AuthenticatorInterface>(tcp, URL);
            var    auth        = authFactory.CreateChannel();

            try
            {
                val = auth.Login(name, password);

                //Checks if token was a valid return, ie. if it was a successful login
                //The token is stored in a singleton called DataSingleton that is accessible on client side
                if (int.TryParse(val, out DataSingleton.Instance.token))
                {
                    ErrorText.Text = "";
                    //If logged in move to menu
                    MenuWindow win = new MenuWindow();
                    win.Show();
                    this.Hide();
                }
                else
                {
                    ErrorText.Text = val;
                }
            }
            catch (Exception ex)
            {
                ErrorText.Text = ex.Message;
            }
        }
Пример #3
0
        private void LoginInClick(object sender, RoutedEventArgs e)
        {
            string username = usernameTextBox.Text;
            string password = passwordBox.Password;

            if (helper.validate_input(username) && helper.validate_input(password))
            {
                LoginRequest  login_request = new LoginRequest(username, password);
                var           json          = new JavaScriptSerializer().Serialize(login_request);
                string        msg           = Constants.LOGIN_ID.ToString() + json.Length.ToString() + json;
                string        response      = helper.SendAndRecive(msg);
                LoginResponse loginResponse = new JavaScriptSerializer().Deserialize <LoginResponse>(response);
                if (loginResponse.status == Constants.SUCCESS_STATUS)//success status
                {
                    Helper.set_username(username);
                    MenuWindow menuWindow = new MenuWindow();
                    menuWindow.Show();
                    this.Close();
                    //MessageBox.Show("Success!");
                }
                else
                {
                    MessageBox.Show("Try again!");
                }
            }
            else
            {
                MessageBox.Show("input contain only latters and digits");
            }
        }
        //Returns user to menu
        private void BackButton_Click(object sender, RoutedEventArgs e)
        {
            MenuWindow menu = new MenuWindow();

            menu.Show();
            this.Hide();
        }
Пример #5
0
        private void ExitClick(object sender, RoutedEventArgs e)
        {
            string     request    = Constants.LEAVE_GAME_ID.ToString() + "0";
            string     response   = helper.SendAndRecive(request);
            MenuWindow menuWindow = new MenuWindow();

            menuWindow.Show();
            this.Close();
        }
Пример #6
0
        private void CloseRoom(object sender, RoutedEventArgs e)
        {
            string            request        = Constants.CLOSE_ROOM_ID.ToString() + "0";
            string            response       = helper.SendAndRecive(request);
            CloseRoomResponse signupResponse = new JavaScriptSerializer().Deserialize <CloseRoomResponse>(response);

            MenuWindow menuWindow = new MenuWindow();

            menuWindow.Show();
            this.Close();
        }