Пример #1
0
        /// <summary>
        /// Check for RaumfeldZones
        /// http://www.hifi-forum.de/index.php?action=browseT&forum_id=212&thread=420&postID=220#220
        /// http://www.hifi-forum.de/index.php?action=browseT&forum_id=212&thread=420&postID=271#271
        /// Add CancelationTokkens if necessary
        /// </summary>
        /// <returns></returns>
        private async Task raumfeldGetZones()
        {
            if (mediaServer == null)
            {
                return;
            }

            try
            {
                using (HttpClient client = new HttpClient())
                {
                    using (HttpRequestMessage request = new HttpRequestMessage()
                    {
                        RequestUri = new Uri(HtmlExtension.CompleteHttpString(mediaServer.IpAddress, RaumFeldStaticDefinitions.PORT_WEBSERVICE, RaumFeldStaticDefinitions.GETZONES)), Method = HttpMethod.Get
                    })
                    {
                        if (!string.IsNullOrEmpty(raumfeldGetZonesUpdateId))
                        {
                            request.Headers.Add("updateID", raumfeldGetZonesUpdateId);
                        }
                        using (HttpResponseMessage response = await client.SendRequestAsync(request))
                        {
                            if (response.StatusCode == HttpStatusCode.Ok)
                            {
                                raumfeldGetZonesUpdateId = response.Headers["updateID"];
                                string xmlResponse = await response.Content.ReadAsStringAsync();

                                raumFeldZoneConfig = XmlExtension.Deserialize <RaumFeldZoneConfig>(xmlResponse);

                                await matchRaumfeldZones();

                                await raumfeldGetZones();
                            }
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                throw new Exception();

                await messagingService.ShowErrorDialogAsync(exception);
            }
        }
Пример #2
0
        private async Task loadServicesAsync()
        {
            ServiceTypes serviceType;

            foreach (Service service in deviceDescription.Device.Services)
            {
                switch (service.ServiceType)
                {
                case ServiceTypesString.AVTRANSPORT:
                    AVTransport = await XmlExtension.DeserializeUriAsync <AVTransport>(new Uri(HtmlExtension.CompleteHttpString(ipAddress, port, service.SCPDURL)));

                    AVTransport.SetParent();
                    serviceType = ServiceTypes.AVTRANSPORT;
                    break;

                case ServiceTypesString.CONNECTIONMANAGER:
                    ConnectionManager = await XmlExtension.DeserializeUriAsync <ConnectionManager>(new Uri(HtmlExtension.CompleteHttpString(ipAddress, port, service.SCPDURL)));

                    ConnectionManager.SetParent();
                    serviceType = ServiceTypes.CONNECTIONMANAGER;
                    break;

                case ServiceTypesString.CONTENTDIRECTORY:
                    ContentDirectory = await XmlExtension.DeserializeUriAsync <ContentDirectory>(new Uri(HtmlExtension.CompleteHttpString(ipAddress, port, service.SCPDURL)));

                    ContentDirectory.SetParent();
                    serviceType = ServiceTypes.CONTENTDIRECTORY;
                    break;

                case ServiceTypesString.MEDIARECEIVERREGISTRAR:
                    MediaReceiverRegistrar = await XmlExtension.DeserializeUriAsync <MediaReceiverRegistrar>(new Uri(HtmlExtension.CompleteHttpString(ipAddress, port, service.SCPDURL)));

                    MediaReceiverRegistrar.SetParent();
                    serviceType = ServiceTypes.MEDIARECEIVERREGISTRAR;
                    break;

                case ServiceTypesString.RENDERINGCONTROL:
                    RenderingControl = await XmlExtension.DeserializeUriAsync <RenderingControl>(new Uri(HtmlExtension.CompleteHttpString(ipAddress, port, service.SCPDURL)));

                    RenderingControl.SetParent();
                    serviceType = ServiceTypes.RENDERINGCONTROL;
                    break;

                default:
                    serviceType = ServiceTypes.NEUTRAL;
                    break;
                }

                if (serviceType != ServiceTypes.NEUTRAL)
                {
                    serviceSCPDs.Add(new NetWorkSubscriberPayload {
                        MediaDevice = this, URI = HtmlExtension.CompleteHttpString(ipAddress, port, service.SCPDURL), ServiceType = serviceType,
                    });
                    serviceControls.Add(new NetWorkSubscriberPayload {
                        MediaDevice = this, URI = HtmlExtension.CompleteHttpString(ipAddress, port, service.ControlURL), ServiceType = serviceType,
                    });
                    serviceEvents.Add(new NetWorkSubscriberPayload {
                        MediaDevice = this, URI = HtmlExtension.CompleteHttpString(ipAddress, port, service.EventSubURL), ServiceType = serviceType,
                    });
                }
            }
        }