private void JoinBtn_Click(object sender, EventArgs e) { var username = UsernameTxtBox.Text; if (ValidateUsername(username)) { JoinBtn.Enabled = false; var user = UserFactory.CreateUser(username); Client = new TcpSocketClient(user, "127.0.0.1", 6009); TcpClient = Client.CreateTcpConnection(Client.Ip, Client.Port); NetworkStream = Client.CreateNetworkStream(TcpClient); Client.SendMessage(NetworkStream, $"join:{user.Username}"); var response = Client.ReceivedMessage(NetworkStream); if (response.Equals("DuplicateUser")) { JoinBtn.Enabled = true; MessageBox.Show("Duplicated Username Error"); } else { ChatMessageRichTxtBox.Text += response; ChatMessageRichTxtBox.Text += "\n"; ShowBroadCastMessages(NetworkStream); button1.Enabled = true; } } }