private void button1_Click(object sender, EventArgs e) { try { if (string.IsNullOrEmpty(textBox1.Text)) { MessageBox.Show("Invalid Nickname", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (string.IsNullOrEmpty(textBox2.Text)) { MessageBox.Show("Invalid Password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if ((user = broker.Login(textBox1.Text, textBox2.Text, new IPEndPoint(Util.LocalIPAddress(), port))) != null) { this.Hide(); (new MainWindow(user, port)).Show(); } else { MessageBox.Show("Invalid nickname or password.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception ex) { user = null; Console.WriteLine(ex.Message + " -- " + ex.StackTrace); MessageBox.Show("Error contacting the server", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }