private void btnConnect_Click(object sender, EventArgs e) { string name = textBoxUserName.Text; string pass = textBoxUserPassword.Text; int port; string addr; if (textBoxServer.Text.Contains(':')) { var server = textBoxServer.Text.Split(':'); addr = server[0]; port = Int32.Parse(server[1]); } else { addr = textBoxServer.Text; port = 64738; } if (connection != null) { connection.Close(); connection = null; protocol.Close(); tvUsers.Nodes.Clear(); } connection = new MumbleConnection(new IPEndPoint(Dns.GetHostAddresses(addr).First(a => a.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork), port), protocol); connection.Connect(name, pass, new string[0], addr); while (connection.Protocol.LocalUser == null) { connection.Process(); } }
private void button2_Click(object sender, EventArgs e) { string name = textBox1.Text; string pass = ""; int port = 64738; string addr = textBox2.Text; if (connection != null) { connection.Close(); connection = null; protocol.Close(); tvUsers.Nodes.Clear(); } connection = new MumbleConnection(new IPEndPoint(Dns.GetHostAddresses(addr).First(a => a.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork), port), protocol); connection.Connect(name, pass, new string[0], addr); while (connection.Protocol.LocalUser == null) { connection.Process(); } }