private void buttonStart_Click(object sender, EventArgs e) { switch (comboBoxTestType.SelectedIndex) { case 0: { acceptorTest = new ReactorAcceptorTest(addresses[comboBoxLocalAddresses.SelectedIndex], Int32.Parse(textBoxLocalPort.Text), 500000, 2, false, false); acceptorTest.SocketEvent += OnSocketEvent; OnStart_FormChanges(); break; } case 1: { connectorTest = new ReactorConnectorTest(500000); IPEndPoint endPoint = new IPEndPoint(IPAddress.Parse(textBoxRemoteAddress.Text), Int32.Parse(textBoxRemotePort.Text)); connectorTest.AddConnection(endPoint, false, false); connectorTest.SocketEvent += OnSocketEvent; OnStart_FormChanges(); break; } case 2: { acceptorTest = new ReactorAcceptorTest(addresses[comboBoxLocalAddresses.SelectedIndex], Int32.Parse(textBoxLocalPort.Text), 500000, 2, true, false); acceptorTest.SocketEvent += OnSocketEvent; OnStart_FormChanges(); break; } case 3: { connectorTest = new ReactorConnectorTest(500000); IPEndPoint endPoint = new IPEndPoint(IPAddress.Parse(textBoxRemoteAddress.Text), Int32.Parse(textBoxRemotePort.Text)); connectorTest.AddConnection(endPoint, true, false); connectorTest.SocketEvent += OnSocketEvent; OnStart_FormChanges(); break; } case 4: { IPEndPoint localEndPoint = new IPEndPoint(addresses[comboBoxLocalAddresses.SelectedIndex], Int32.Parse(textBoxLocalPort.Text)); IPEndPoint remoteEndPoint = new IPEndPoint(IPAddress.Parse(textBoxRemoteAddress.Text), Int32.Parse(textBoxRemotePort.Text)); udpTest = new ReactorUdpTest(ReactorUdpTest.UdpTestType.BROADCAST, localEndPoint, remoteEndPoint, 5000000); udpTest.SocketEvent += OnSocketEvent; OnStart_FormChanges(); EnableMessageBox(true); break; } case 5: { IPEndPoint localEndPoint = new IPEndPoint(addresses[comboBoxLocalAddresses.SelectedIndex], Int32.Parse(textBoxLocalPort.Text)); IPEndPoint remoteEndPoint = new IPEndPoint(IPAddress.Parse(textBoxRemoteAddress.Text), Int32.Parse(textBoxRemotePort.Text)); udpTest = new ReactorUdpTest(ReactorUdpTest.UdpTestType.MULTICAST, localEndPoint, remoteEndPoint, 5000000); udpTest.SocketEvent += OnSocketEvent; OnStart_FormChanges(); EnableMessageBox(true); break; } case 6: { IPEndPoint localEndPoint = new IPEndPoint(addresses[comboBoxLocalAddresses.SelectedIndex], Int32.Parse(textBoxLocalPort.Text)); IPEndPoint remoteEndPoint = new IPEndPoint(IPAddress.Parse(textBoxRemoteAddress.Text), Int32.Parse(textBoxRemotePort.Text)); udpTest = new ReactorUdpTest(ReactorUdpTest.UdpTestType.P2P, localEndPoint, remoteEndPoint, 5000000); udpTest.SocketEvent += OnSocketEvent; OnStart_FormChanges(); EnableMessageBox(true); break; } case 7: { acceptorTest = new ReactorAcceptorTest(addresses[comboBoxLocalAddresses.SelectedIndex], Int32.Parse(textBoxLocalPort.Text), 500000, 2, false, true); acceptorTest.SocketEvent += OnSocketEvent; OnStart_FormChanges(); break; } case 8: { connectorTest = new ReactorConnectorTest(500000); IPEndPoint endPoint = new IPEndPoint(IPAddress.Parse(textBoxRemoteAddress.Text), Int32.Parse(textBoxRemotePort.Text)); connectorTest.AddConnection(endPoint, false, true); connectorTest.SocketEvent += OnSocketEvent; OnStart_FormChanges(); break; } default: break; } }
private void buttonStop_Click(object sender, EventArgs e) { switch (comboBoxTestType.SelectedIndex) { case 0: { acceptorTest.Running = false; acceptorTest.SocketEvent -= OnSocketEvent; acceptorTest = null; OnStop_FormChanges(); break; } case 1: { connectorTest.Running = false; connectorTest.SocketEvent -= OnSocketEvent; connectorTest = null; OnStop_FormChanges(); break; } case 2: { acceptorTest.Running = false; acceptorTest.SocketEvent -= OnSocketEvent; acceptorTest = null; OnStop_FormChanges(); break; } case 3: { connectorTest.Running = false; connectorTest.SocketEvent -= OnSocketEvent; connectorTest = null; OnStop_FormChanges(); break; } case 4: { udpTest.Running = false; udpTest.SocketEvent -= OnSocketEvent; udpTest = null; OnStop_FormChanges(); break; } case 5: { udpTest.Running = false; udpTest.SocketEvent -= OnSocketEvent; udpTest = null; OnStop_FormChanges(); break; } case 6: { udpTest.Running = false; udpTest.SocketEvent -= OnSocketEvent; udpTest = null; OnStop_FormChanges(); break; } case 7: { acceptorTest.Running = false; acceptorTest.SocketEvent -= OnSocketEvent; acceptorTest = null; OnStop_FormChanges(); break; } case 8: { connectorTest.Running = false; connectorTest.SocketEvent -= OnSocketEvent; connectorTest = null; OnStop_FormChanges(); break; } default: break; } }