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);
     }
 }
Beispiel #2
0
 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);
     }
 }
Beispiel #3
0
 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");
 }
Beispiel #4
0
 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);
     }
 }
Beispiel #5
0
 private void LogoutSession()
 {
     UnsubscribeServerNotifications();
     ClientApp.GetServer().LogoutUser(ClientApp.GetLoggedUser());
 }
Beispiel #6
0
 private void UnsubscribeServerNotifications()
 {
     ClientApp.GetServer().NewUserHandler    -= new NewActiveUser(_newUserRepeater.Repeater);
     ClientApp.GetServer().LogoutUserHandler -= new LogoutActiveUser(_logoutUserRepeater.Repeater);
     Console.WriteLine(@"Client App unsubscribed with success");
 }