private void hostBtn_Click(object sender, EventArgs e) // Host Button { if (isIngame) { MessageBox.Show("Please stay in the main menu before starting a session!", "Error"); // Prevent the user from hosting/connecting while being ingame return; } WriteToTABS("HOSTNOW"); // Send the host command button1.Enabled = false; // Disable the host btn button2.Enabled = false; // Disable the connection btn isHost = true; new Thread(() => ScreenshotHandler.UdpThread()).Start(); // Start the udp listener }
private void connectBtn_Click(object sender, EventArgs e) // Connect Button { if (isIngame) { MessageBox.Show("Please stay in/enter the main menu before starting a session!", "Error"); return; } try { WriteToTABS("CONNECT|" + IPAddress.Parse(textBox1.Text).ToString()); // Send connect cmd + ip with parse checking button1.Enabled = false; // Disable the host btn button2.Enabled = false; // Disable the connection btn screenPartner = new IPEndPoint(IPAddress.Parse(textBox1.Text), 8042); // Connect to the other screenClient screenClient.Connect(screenPartner); new Thread(() => ScreenshotHandler.UdpThread()).Start(); // Start the udp listener ScreenshotHandler.WriteToUdp(StrToByte("HELLO")); // Send hello } catch (Exception) { MessageBox.Show("Invalid IP!", "Error"); } }