//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; } }
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"); } }
private void Back_Click(object sender, RoutedEventArgs e) { MenuWindow menuWindow = new MenuWindow(); menuWindow.Show(); this.Close(); }
//Returns user to menu private void BackButton_Click(object sender, RoutedEventArgs e) { MenuWindow menu = new MenuWindow(); menu.Show(); this.Hide(); }
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(); }
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(); }