public void connect() { if (connected) { // Remove the listener controller.RemoveListener(listener); controller.Dispose(); connected = false; connectbutton.Text = "Connect"; fps_label.Text = "disconnected"; } else { // Create listener and controller listener = new SampleListener(); listener.form = this; controller = new Controller(); if (controller.IsConnected) { controller.AddListener(listener); connectbutton.Text = "Disconnect"; connected = true; } } }
public void connect() { if (connected) { // Remove the listener controller.RemoveListener(listener); controller.Dispose(); connected = false; connectbutton.Text = "Connect"; fps_label.Text = "disconnected"; } else { // Create listener and controller listener = new SampleListener(); listener.form = this; controller = new Controller(); if (controller.IsConnected) { controller.AddListener(listener); connectbutton.Text = "Disconnect"; connected = true; } } }