private void OnDiscoveryButtonClicked(object sender, EventArgs e) { discoveryMode = !discoveryMode; Button b = sender as Button; if (b == null) { return; } var discovery = DeviceDiscovery.GetInstance(); if (discoveryMode) { //Start mDNS discovery b.Text = "Stop discovery"; devicesFoundCount = 0; discovery.ValidDeviceFound += OnDeviceCreated; discoveryResultLabel.IsVisible = true; discoveryResultLabel.Text = "Found no lights yet..."; discovery.StartDiscovery(); } else { //Stop mDNS discovery discovery.StopDiscovery(); discovery.ValidDeviceFound -= OnDeviceCreated; b.Text = "Discover lights..."; } }
public static DeviceDiscovery GetInstance() { if (Instance == null) { Instance = new DeviceDiscovery(); } return(Instance); }
protected override void OnDisappearing() { //stop discovery if running if (discoveryMode) { var discovery = DeviceDiscovery.GetInstance(); discovery.StopDiscovery(); discovery.ValidDeviceFound -= OnDeviceCreated; } }