/** * Function to handle informing the server of a client disconnecting, closing the socket and quitting the application. */ private void ExitBtn_Click(object sender, EventArgs e) { AppFunctions.SendText("/exit", mClientSocket, mSendData); mClientSocket.Shutdown(SocketShutdown.Both); mClientSocket.Close(); Application.Exit(); }
/** * Function for detecting when the enter key is pressed whilst focused on the sendTxt textbox and sending the data. */ private void SendTxt_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode.Equals(Keys.Enter)) { AppFunctions.SendText(sendTxt.Text, mClientSocket, mSendData); sendTxt.Clear(); e.SuppressKeyPress = true; } }
/** * Function to handle sending data to the server when the send button is clicked. */ private void SendBtn_Click(object sender, EventArgs e) { try { AppFunctions.SendText(sendTxt.Text, mClientSocket, mSendData); sendTxt.Clear(); } catch (Exception) { UpdateControlStates(false); } }