Exemplo n.º 1
0
 /// <summary>
 /// Handler for CpDeviceList if devices are removed from the network (they should 
 /// send a bye if they went offline, or announcement keep alive is over).
 /// </summary>
 /// <param name="aList"></param>
 /// <param name="aDevice"></param>
 private void DeviceRemoved(OpenHome.Net.ControlPoint.CpDeviceList aList, OpenHome.Net.ControlPoint.CpDevice aDevice)
 {
     String udn = aDevice.Udn();
     try
     {
         UPnPDevice dev = deviceList [udn];
         lock (deviceList)
         {
             deviceList [udn].Free();
             deviceList.Remove(udn);
         }
         PrintDeviceInfo("Removed", aDevice);
         OnDeviceRemoved(dev);
     } catch (KeyNotFoundException)
     {
         Utils.Logger.Log(Utils.Logger.Level.Error, "Wanted to remove a UPnP-Device from my list but it's already gone!? :/");
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Prints some device information.
 /// </summary>
 /// <param name="aPrologue"></param>
 /// <param name="aDevice"></param>
 private void PrintDeviceInfo(string aPrologue, OpenHome.Net.ControlPoint.CpDevice aDevice)
 {
     string location;
     aDevice.GetAttribute("Upnp.Location", out location);
     string friendlyName;
     aDevice.GetAttribute("Upnp.FriendlyName", out friendlyName);
     Utils.Logger.Log(Utils.Logger.Level.Debug,
         aPrologue +
         "\n    udn = " + aDevice.Udn() +
         "\n    location = " + location +
         "\n    name = " + friendlyName
     );
 }
Exemplo n.º 3
0
        /// <summary>
        /// Handler for CpDeviceList if devices are found on the network.
        /// </summary>
        /// <param name="aList"></param>
        /// <param name="aDevice"></param>
        private void DeviceAdded(OpenHome.Net.ControlPoint.CpDeviceList aList, OpenHome.Net.ControlPoint.CpDevice aDevice)
        {
            lock (deviceList)
            {
                PrintDeviceInfo("Found", aDevice);

                string deviceXml;
                aDevice.GetAttribute("Upnp.DeviceXml", out deviceXml);

                XmlDocument xmlDeviceDescription = new XmlDocument();
                xmlDeviceDescription.LoadXml(deviceXml);

                if (UPnPTools.isMediaRenderer(xmlDeviceDescription))
                {
                    deviceList.Add(aDevice.Udn(), new UPnPDevice(aDevice, xmlDeviceDescription));
                    Utils.Logger.Log(Utils.Logger.Level.Debug, "Found usefull MediaRenderer: " + deviceList [aDevice.Udn()].FriendlyName);
                    OnDeviceDiscovered(deviceList [aDevice.Udn()]);
                }
            }
        }