Exemple #1
0
        private async void GetDeviceDescribtionAsync(string usn, string location)
        {
            string url = location.Trim();
            var    httpResponseMessage = await _httpClient.GetAsync(url);

            // check the response
            if (httpResponseMessage.StatusCode != HttpStatusCode.OK)
            {
                return;
            }
            var response = await httpResponseMessage.Content.ReadAsStreamAsync();

            XDocument rxDocument  = XDocument.Load(response);
            var       describtion = AVRDeviceDescribtion.ReadFromXDocument(rxDocument);

            if (describtion == null)
            {
                return;
            }
            AVRDevice avrDevice = null;

            lock (mutex_AVRservice)
            {
                if (_avrServices.ContainsKey(usn))
                {
                    return;
                }
                avrDevice = new AVRDevice(usn, describtion);
                _avrServices.Add(usn, avrDevice);
            }
            OnAVRServiceAdded(avrDevice);
        }
Exemple #2
0
 protected virtual void OnAVRServiceAdded(AVRDevice e)
 {
     if (AVRDevicAdded != null && e != null)
     {
         AVRDevicAdded(this, e);
     }
 }
Exemple #3
0
        public bool CennectToDevice(AVRDevice device)
        {
            if (device?.Usn == null)
            {
                return(false);
            }
            bool success = _avrServices.TryGetValue(device.Usn, out _connectedAvrDevice);

            if (success)
            {
                FalichsLogger.Instance.log(FalichsLogger.Severity.INFO, "Connected to " + device?.AvrDeviceDescribtion?.FriendlyName);
                _freshConnection = true;
                UpdateDeviceData();
                _updateTimer.Start();
            }
            else
            {
                FalichsLogger.Instance.log(FalichsLogger.Severity.WARNING, "Failed to connected to " + device?.AvrDeviceDescribtion?.FriendlyName);
            }
            return(success);
        }