Ejemplo n.º 1
0
 private void CheckTvInitialized(TvDiscovery.Tv2014InitInfo tv)
 {
     try
     {
         HttpMessage httpMessages  = new HttpMessage(tv.ServiceUri);
         HttpMessage httpMessages1 = this.transport.SendRequest(httpMessages);
         if (!string.IsNullOrEmpty(httpMessages1.Content))
         {
             if (JObject.Parse(httpMessages1.Content) != null)
             {
                 this.foundTvs.Remove(tv);
                 this.devicePool.Add(tv.DeviceInfo);
             }
             else
             {
                 return;
             }
         }
     }
     catch (WebException webException)
     {
     }
     catch (JsonException jsonException)
     {
     }
 }
Ejemplo n.º 2
0
 private void upnpDiscovery_DeviceDisconnected(object sender, DeviceInfoEventArgs e)
 {
     TvDiscovery.Tv2014InitInfo tv2014InitInfo = this.foundTvs.Find((TvDiscovery.Tv2014InitInfo arg) => arg.DeviceInfo.UniqueServiceName == e.DeviceInfo.UniqueServiceName);
     if (tv2014InitInfo != null)
     {
         this.foundTvs.Remove(tv2014InitInfo);
     }
     this.devicePool.Remove(e.DeviceInfo.UniqueServiceName);
 }
Ejemplo n.º 3
0
 private void upnpDiscovery_DeviceConnected(object sender, DeviceInfoEventArgs e)
 {
     if (e.DeviceInfo.DeviceType != "urn:dial-multiscreen-org:device:dialreceiver:1")
     {
         Logger   instance   = Logger.Instance;
         object[] deviceType = new object[] { e.DeviceInfo.DeviceType, e.DeviceInfo.DeviceAddress };
         instance.LogMessageFormat("upnpDiscovery_DeviceConnected Device is not Dial Receiver, TV type is {0}, with address: {1}.", deviceType);
         return;
     }
     TvDiscovery.Tv2014InitInfo tv2014Data = TvDiscovery.GetTv2014Data(e.DeviceInfo);
     if (tv2014Data != null)
     {
         Console.WriteLine("Model 2014 Samsung TV found.");
         this.foundTvs.Add(tv2014Data);
         return;
     }
     Console.WriteLine("Pre 2014 Samsung TV found");
     this.devicePool.Add(e.DeviceInfo);
 }
Ejemplo n.º 4
0
 private static TvDiscovery.Tv2014InitInfo GetTv2014Data(DeviceInfo deviceInfo)
 {
     TvDiscovery.Tv2014InitInfo tv2014InitInfo;
     using (TextReader stringReader = new StringReader(deviceInfo.SourceXml))
     {
         XmlDocument xmlDocument = new XmlDocument();
         xmlDocument.Load(stringReader);
         XmlNodeList elementsByTagName = xmlDocument.GetElementsByTagName("Capability", "http://www.sec.co.kr/dlna");
         if (elementsByTagName == null || elementsByTagName.Count == 0)
         {
             tv2014InitInfo = null;
         }
         else
         {
             foreach (XmlElement xmlElement in elementsByTagName)
             {
                 if (xmlElement.GetAttribute("name") != "samsung:multiscreen:1")
                 {
                     continue;
                 }
                 UriBuilder uriBuilder = new UriBuilder(deviceInfo.DeviceAddress)
                 {
                     Port = int.Parse(xmlElement.GetAttribute("port")),
                     Path = xmlElement.GetAttribute("location")
                 };
                 TvDiscovery.Tv2014InitInfo tv2014InitInfo1 = new TvDiscovery.Tv2014InitInfo()
                 {
                     DeviceInfo = deviceInfo,
                     ServiceUri = uriBuilder.Uri
                 };
                 tv2014InitInfo = tv2014InitInfo1;
                 return(tv2014InitInfo);
             }
             return(null);
         }
     }
     return(tv2014InitInfo);
 }
Ejemplo n.º 5
0
 private void FindInitializedDevices()
 {
     TvDiscovery.Tv2014InitInfo[] array = new TvDiscovery.Tv2014InitInfo[0];
     array = this.foundTvs.ToArray <TvDiscovery.Tv2014InitInfo>();
     Parallel.ForEach <TvDiscovery.Tv2014InitInfo>(array, (TvDiscovery.Tv2014InitInfo tv) => this.CheckTvInitialized(tv));
 }