Udn() public method

Query the unique identifier associated with a device
public Udn ( ) : String
return String
Exemplo n.º 1
0
 private void PollSubscribe()
 {
     iSubscriptionSem = new Semaphore(0, 1);
     for (int i = 0; i < iDeviceList.Count; i++)
     {
         ControlPoint.CpDevice device = iDeviceList[i];
         string udn = device.Udn();
         if (udn == "896659847466-a4badbeaacbc-737837" ||
             udn == "541d0cb5-3b34-4264-8ff0-d8653acf6425")
         {
             continue;
         }
         uint countBefore = iSubscriptionCount;
         Console.Write("Device " + device.Udn());
         ControlPoint.Proxies.CpProxyUpnpOrgConnectionManager1 connMgr = new ControlPoint.Proxies.CpProxyUpnpOrgConnectionManager1(device);
         connMgr.SetPropertyChanged(PropertyChanged);
         DateTime startTime = DateTime.Now;
         while (true)
         {
             connMgr.Subscribe();
             iSubscriptionSem.WaitOne((int)(2 * kDevicePollMs));
             connMgr.Unsubscribe();
             DateTime now = DateTime.Now;
             if (now.Subtract(startTime).TotalSeconds > kDevicePollSecs)
             {
                 break;
             }
             iSubscriptionCount++;
         }
         Console.Write("    " + (iSubscriptionCount - countBefore) + "\n");
         connMgr.Dispose();
     }
 }
Exemplo n.º 2
0
 private void InvokeSync()
 {
     // trivial validation of the sync wrappers to all APIs
     // single sync call to whichever device happens to be first in our list
     if (iDeviceList.Count == 0)
     {
         Console.Write("No devices found, so nothing to test\n");
         return;
     }
     ControlPoint.CpDevice device = iDeviceList[0];
     Console.Write("\n\nSync call to device " + device.Udn() + "\n");
     ControlPoint.Proxies.CpProxyUpnpOrgConnectionManager1 connMgr = new ControlPoint.Proxies.CpProxyUpnpOrgConnectionManager1(device);
     try
     {
         string source;
         string sink;
         connMgr.SyncGetProtocolInfo(out source, out sink);
         Console.Write("source is " + source + "\nsink is " + sink + "\n");
     }
     catch (ControlPoint.ProxyError)
     {
         Console.WriteLine("...failed.  (This may be expected but shouldn't be easily reproducible.)");
     }
     connMgr.Dispose();
 }
Exemplo n.º 3
0
 private void PollInvoke()
 {
     iActionPollStop = new Semaphore(0, 1);
     System.Timers.Timer timer = new System.Timers.Timer();
     timer.Elapsed  += TimerElapsed;
     timer.AutoReset = false;
     for (int i = 0; i < iDeviceList.Count; i++)
     {
         ControlPoint.CpDevice device = iDeviceList[i];
         uint countBefore             = iActionCount;
         Console.Write("Device " + device.Udn());
         iConnMgr            = new ControlPoint.Proxies.CpProxyUpnpOrgConnectionManager1(device);
         iActionPollStopTime = DateTime.Now.AddMilliseconds(kDevicePollMs);
         timer.Interval      = kDevicePollMs;
         timer.Enabled       = false;
         timer.Enabled       = true;
         for (int j = 0; j < 4; j++)
         {
             iConnMgr.BeginGetProtocolInfo(GetProtocolInfoComplete);
         }
         iActionPollStop.WaitOne();
         Console.Write("    " + (iActionCount - countBefore) + "\n");
         iConnMgr.Dispose();
         lock (this)
         {
             iExpectedSink = null;
         }
     }
 }
Exemplo n.º 4
0
 private void DeviceAdded(CpDeviceList aList, CpDevice aDevice)
 {
     lock (this)
     {
         if (iDeviceList.Count == 0 && aDevice.Udn() == DeviceBasic.gDeviceName)
         {
             aDevice.AddRef();
             iDeviceList.Add(aDevice);
         }
     }
 }
Exemplo n.º 5
0
        private void PrintDeviceInfo(string aPrologue, ControlPoint.CpDevice aDevice)
        {
            string location;

            aDevice.GetAttribute("Upnp.Location", out location);
            string friendlyName;

            aDevice.GetAttribute("Upnp.FriendlyName", out friendlyName);
            Console.Write(aPrologue +
                          "\n    udn = " + aDevice.Udn() +
                          "\n    location = " + location +
                          "\n    name = " + friendlyName + "\n");
        }
Exemplo n.º 6
0
 private void DeviceRemoved(ControlPoint.CpDeviceList aList, ControlPoint.CpDevice aDevice)
 {
     lock (this)
     {
         if (!iListFrozen)
         {
             PrintDeviceInfo("Removed", aDevice);
             string udn   = aDevice.Udn();
             int    count = iDeviceList.Count;
             for (int i = 0; i < count; i++)
             {
                 if (iDeviceList[i].Udn() == udn)
                 {
                     iDeviceList[i].RemoveRef();
                     iDeviceList.RemoveAt(i);
                     break;
                 }
             }
         }
     }
 }
Exemplo n.º 7
0
 private static void CallListChangedDelegate(ChangeHandler aDelegate, CpDeviceList aList, CpDevice aDevice)
 {
     try
     {
         aDelegate(aList, aDevice);
     }
     catch (Exception e)
     {
         System.Diagnostics.Debug.WriteLine(String.Format("WARNING: Unhandled exception in device list change delegate.\n\tDevice is {0}\n\tException is {1}", aDevice.Udn(), new object[] { e }));
     }
 }
Exemplo n.º 8
0
 private void DeviceRemoved(CpDeviceList aList, CpDevice aDevice)
 {
     lock (this)
     {
         string udn = aDevice.Udn();
         int count = iDeviceList.Count;
         for (int i = 0; i < count; i++)
         {
             if (iDeviceList[i].Udn() == udn)
             {
                 iDeviceList.RemoveAt(i);
                 iDeviceList[i].RemoveRef();
             }
         }
     }
 }
Exemplo n.º 9
0
        public CpAVRenderer_OhNet(OpenHome.Net.ControlPoint.CpDevice _rendererDevice)
        {
            XMLParser xmlParser = new XMLParser();

                renderingControl = new CpProxyUpnpOrgRenderingControl1(_rendererDevice);
                renderingControl.SetPropertyInitialEvent(propertyChanged);
                renderingControl.SetPropertyChanged(propertyChanged);
                renderingControl.SetPropertyLastChangeChanged(propertyChanged);
                renderingControl.Subscribe();

                avRendererDevice = _rendererDevice;
                avRendererDevice.GetAttribute("Upnp.DeviceXml", out DeviceXml);

                ModelDescription = xmlParser.getNodeValue(DeviceXml, "modelDescription");
                FriendlyName = xmlParser.getNodeValue(DeviceXml, "friendlyName");
                Manufacturer = xmlParser.getNodeValue(DeviceXml, "manufacturer");
                UniqueDeviceName = avRendererDevice.Udn();

                Connections = new List<CpAVConnection>();
                Connections.Add(new CpAVConnection_OhNet(avRendererDevice));
        }
Exemplo n.º 10
0
 public void DeviceRemoved(CpDevice aDevice)
 {
     string udn = aDevice.Udn();
     Logger.DebugFormat("DeviceRemoved: UDN={0}", udn);
     ProxyRecord oldProxyRecord = null;
     lock (iProxiesByUdn)
     {
         if (iProxiesByUdn.ContainsKey(udn))
         {
             oldProxyRecord = iProxiesByUdn[udn];
             iProxiesByUdn.Remove(udn);
         }
     }
     if (oldProxyRecord != null)
     {
         oldProxyRecord.InvokeDisappeared();
         oldProxyRecord.Ref.Dispose();
         oldProxyRecord.Device.RemoveRef();
     }
 }
Exemplo n.º 11
0
 public void DeviceAdded(CpDevice aDevice)
 {
     string udn = aDevice.Udn();
     Logger.DebugFormat("DeviceAdded: UDN={0}", udn);
     CountedReference<T> newProxyRef = new CountedReference<T>(iProxyConstructor(aDevice));
     aDevice.AddRef();
     ProxyRecord newProxyRecord = new ProxyRecord(aDevice, newProxyRef);
     ProxyRecord oldProxyRecord = null;
     EventHandler<ProxyEventArgs> handler;
     lock (iProxiesByUdn)
     {
         if (iProxiesByUdn.ContainsKey(udn))
         {
             oldProxyRecord = iProxiesByUdn[udn];
         }
         iProxiesByUdn[aDevice.Udn()] = newProxyRecord;
         handler = DeviceDetectedHandler;
         Monitor.PulseAll(iProxiesByUdn);
     }
     if (oldProxyRecord != null)
     {
         oldProxyRecord.InvokeDisappeared();
         oldProxyRecord.Ref.Dispose();
         oldProxyRecord.Device.RemoveRef();
     }
     if (handler != null)
     {
         handler(this, new ProxyEventArgs(aDevice, newProxyRef, newProxyRecord));
     }
 }