public void Dispose()
 {
     if (_client != null)
     {
         _client.DeviceDiscovered -= _client_DeviceDiscovered;
         _client.DeviceLost       -= _client_DeviceLost;
         _client.StopDeviceDiscovery();
         _client.Dispose();
     }
 }
예제 #2
0
        public async Task <List <LifxData> > Discover(int timeOut)
        {
            if (_client == null)
            {
                return(new List <LifxData>());
            }
            bulbs = new List <LightBulb>();
            _client.DeviceDiscovered += Client_DeviceDiscovered;
            _client.StartDeviceDiscovery();
            LogUtil.Write("Lifx: Discovery started.");
            await Task.Delay(timeOut * 1000);

            LogUtil.Write("Discovery completed.");
            _client.StopDeviceDiscovery();
            return(bulbs.Select(GetBulbInfo).ToList());
        }