/// <summary> /// Checks if the username and passwords are empty or not, /// validates password's lenth; /// if all requirements are met, starts the client, sending a request to the server; /// </summary> private void materialRaisedButton1_Click(object sender, EventArgs e) { userNickname = InputNickname.Text; string userPassword = InputPassword.Text; if (!String.IsNullOrEmpty(userNickname) && !String.IsNullOrEmpty(userPassword)) { if (userPassword.Length < 6) { MessageBox.Show("The password must be at least 6 characters."); } else { LoginForm currentForm = this; var asyncClientEvent = new AsyncClientEvent { }; asyncClientEvent.StartClientWithLoginForm(userNickname, userPassword, "Login", "null", currentForm); } } else { MessageBox.Show("Please fill in all the balnks"); } }
private void DeleteButton_Click(object sender, EventArgs e) { var asyncClientEvent = new AsyncClientEvent { }; asyncClientEvent.StartClientWithChatFormDeleteMessage(userName, messageTimeStamp, "Delete_Message", currentChatForm); }
/// <summary> /// Performs all the necessary checks to the data, /// validating the length of them, and sends a request to the server /// through the AsyncClientEvent class; /// </summary> private void materialRaisedButton1_Click(object sender, EventArgs e) { Guid guid = Guid.NewGuid(); string ID = guid.ToString(); userID = ID; userNickname = InputNickname.Text; string userPassword = InputPassword.Text; if (!String.IsNullOrEmpty(userNickname) && !String.IsNullOrEmpty(userPassword)) { if (userPassword.Length < 6) { MessageBox.Show("The password must be at least 6 characters."); } else { RegisterForm currentForm = this; var asyncClientEvent = new AsyncClientEvent { }; asyncClientEvent.StartClientWithRegisterForm(userNickname, userPassword, "Register", userID, currentForm); } } else { MessageBox.Show("Please fill in all the balnks"); } }
/// <summary> /// Sends a request to the server through the /// AsyncClientEvent, in order to get all the messages in the chat /// </summary> private void getMessages() { Messager currentForm = this; var asyncClientEvent = new AsyncClientEvent { }; asyncClientEvent.StartClientWithChatForm("null", "null", "Get_Messages", "null", currentForm, "null"); }
/// <summary> /// Logs the user out of his account, sending a request to the server; /// </summary> private void LogoutButton_Click(object sender, EventArgs e) { Messager currentForm = this; var asyncClientEvent = new AsyncClientEvent { }; asyncClientEvent.StartClientWithChatFormDisconnect("Disconnect", currentForm); LoginForm loginForm = new LoginForm(); loginForm.Show(); Hide(); }
/// <summary> /// Gets the message from the textbox, validates it; /// Sends a request through the AsyncClientEvent class to the server; /// </summary> private void materialRaisedButton1_Click(object sender, EventArgs e) { String userMessage = MessageTextBox.Text.Trim(); if (!String.IsNullOrEmpty(userMessage)) { MessageTextBox.Text = String.Empty; Messager currentForm = this; var asyncClientEvent = new AsyncClientEvent { }; asyncClientEvent.StartClientWithChatForm(currentUserName, "null", "Send_Message", userID, currentForm, userMessage); } else { MessageBox.Show("Please type in your message"); } }