Exemplo n.º 1
0
        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...";
            }
        }
Exemplo n.º 2
0
 public static DeviceDiscovery GetInstance()
 {
     if (Instance == null)
     {
         Instance = new DeviceDiscovery();
     }
     return(Instance);
 }
Exemplo n.º 3
0
 protected override void OnDisappearing()
 {
     //stop discovery if running
     if (discoveryMode)
     {
         var discovery = DeviceDiscovery.GetInstance();
         discovery.StopDiscovery();
         discovery.ValidDeviceFound -= OnDeviceCreated;
     }
 }