Beispiel #1
0
        public void CreateDeviceAsync(Uri DescriptionURL, int LifeTime)
        {
            UPnPDeviceFactory factory = new UPnPDeviceFactory(DescriptionURL, LifeTime, new UPnPDeviceFactory.UPnPDeviceHandler(this.HandleDeviceCreation), null);

            this.CreateTable[factory] = factory;
            this.Lifetime.Add(factory, 30);
        }
 private void DeviceFactoryCreationSink(UPnPDeviceFactory sender, UPnPDevice device, Uri locationURL)
 {
     if (!this.deviceTable.Contains(device.UniqueDeviceName))
     {
         EventLogger.Log(this, EventLogEntryType.Error, "UPnPDevice[" + device.FriendlyName + "]@" + device.LocationURL + " advertised UDN[" + device.UniqueDeviceName + "] in xml but not in SSDP");
     }
     else
     {
         lock (this.deviceTableLock)
         {
             DeviceInfo info2 = (DeviceInfo)this.deviceTable[device.UniqueDeviceName];
             if (info2.Device != null)
             {
                 EventLogger.Log(this, EventLogEntryType.Information, "Unexpected UPnP Device Creation: " + device.FriendlyName + "@" + device.LocationURL);
                 return;
             }
             DeviceInfo info = (DeviceInfo)this.deviceTable[device.UniqueDeviceName];
             info.Device = device;
             this.deviceTable[device.UniqueDeviceName] = info;
             this.deviceLifeTimeClock.Add(device.UniqueDeviceName, device.ExpirationTimeout);
             this.activeDeviceList.Add(device);
         }
         this.OnAddedDeviceEvent.Fire(this, device);
     }
 }
Beispiel #3
0
 private void HandleDeviceCreation(UPnPDeviceFactory Factory, UPnPDevice device, Uri URL)
 {
     Factory.Shutdown();
     if (this.OnCreateDevice != null)
     {
         this.OnCreateDevice(device, URL);
     }
 }
Beispiel #4
0
 private void FactoryFailedSink(UPnPDeviceFactory sender, Uri URL, Exception e)
 {
     lock (this.CreateTable)
     {
         this.CreateTable.Remove(sender);
         sender.Shutdown();
     }
 }
Beispiel #5
0
 public void CreateDevice(Uri DescLocation, int MaxSeconds)
 {
     lock (this.CreateTable)
     {
         UPnPDeviceFactory factory = new UPnPDeviceFactory(DescLocation, MaxSeconds, new UPnPDeviceHandler(this.HandleFactory), new UPnPDeviceFailedHandler(this.FactoryFailedSink));
         this.CreateTable[factory] = factory;
     }
 }
Beispiel #6
0
 private void HandleFactory(UPnPDeviceFactory Factory, UPnPDevice device, Uri URL)
 {
     lock (this.CreateTable)
     {
         this.CreateTable.Remove(Factory);
     }
     Factory.Shutdown();
     if (this.OnDevice != null)
     {
         this.OnDevice(this, device, URL);
     }
 }