private void registerButton_Click(object sender, EventArgs e) { try { if (passwordBox.Text != textBox2.Text) { MessageBox.Show("Passwords do not match!", "Password", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (ClientApp.GetServer().RegisterUser(nicknameBox.Text, textBox2.Text, passwordBox.Text)) { Console.WriteLine(@"Registration worked"); ActiveUser newUser = ClientApp.GetServer().LoginUser(nicknameBox.Text, passwordBox.Text, ClientApp.GetInstance().Address); if (newUser != null) { ClientApp.SetLoggedUser(newUser); Console.WriteLine(@"Login worked"); this.Hide(); ClientApp.SetMainWindow(new MainWindow(newUser)); ClientApp.GetMainWindow().ShowDialog(); } } else { MessageBox.Show("8 characters minimum;" + Environment.NewLine + "Can not have white spaces, <, >, \' or \"", "Password Rules", MessageBoxButtons.OK); } } catch (Exception ex) { ClientApp.LaunchServerError(ex.Message); } }
private void loginButton_Click(object sender, EventArgs e) { try { ActiveUser newUser = ClientApp.GetServer().LoginUser(nicknameBox.Text, passwordBox.Text, ClientApp.GetInstance().Address); if (newUser != null) { ClientApp.SetLoggedUser(newUser); Console.WriteLine(@"Login worked"); this.Hide(); ClientApp.SetMainWindow(new MainWindow(newUser)); ClientApp.GetMainWindow().ShowDialog(); } else { MessageBox.Show("Login Failed: Be sure that you were registred with those credentials", "Login Failed", MessageBoxButtons.OK, MessageBoxIcon.Information); nicknameBox.Text = ""; passwordBox.Text = ""; } } catch (Exception ex) { ClientApp.LaunchServerError(ex.Message); } }
private void SubscribeServerNotifications() { _newUserRepeater = new NewUserEventRepeater(); _logoutUserRepeater = new LogoutUserEventRepeater(); _newUserRepeater.Handler += new NewActiveUser(AddActiveUser); _logoutUserRepeater.Handler += new LogoutActiveUser(RemoveActiveUser); ClientApp.GetServer().NewUserHandler += new NewActiveUser(_newUserRepeater.Repeater); ClientApp.GetServer().LogoutUserHandler += new LogoutActiveUser(_logoutUserRepeater.Repeater); Console.WriteLine(@"Client App subscribed with success"); }
private void fetchOnlineUsers() { try { _onlineUsers = ClientApp.GetServer().getOnlineUsers(); Console.WriteLine(@"Online users received"); } catch (RemotingException e) { Console.WriteLine(@"Failed to fetch online users"); Console.WriteLine(e); } }
private void LogoutSession() { UnsubscribeServerNotifications(); ClientApp.GetServer().LogoutUser(ClientApp.GetLoggedUser()); }
private void UnsubscribeServerNotifications() { ClientApp.GetServer().NewUserHandler -= new NewActiveUser(_newUserRepeater.Repeater); ClientApp.GetServer().LogoutUserHandler -= new LogoutActiveUser(_logoutUserRepeater.Repeater); Console.WriteLine(@"Client App unsubscribed with success"); }