public void Rescan() { ArrayList l; // We have to copy the list of keys here because we have reports of the hashtable being changed even when the lock is applied; lock (deviceTableLock) { l = new ArrayList(deviceTable.Keys); } foreach (string USN in l) { deviceLifeTimeClock.Add(USN, 20); } genericControlPoint.FindDeviceAsync("upnp:rootdevice"); }
//Add this method override protected override void OnStartup(StartupEventArgs e) { m_Mutex = new Mutex(true, "HomeGenieManagerMutex", out createdNew); //e.Args is the string[] of command line argruments // upnpService = new Dictionary<string, UPnPDevice>(); upnpControl = new UPnPControlPoint(); upnpControl.OnSearch += upnpcontrol_OnSearch; upnpControl.OnCreateDevice += upnpcontrol_OnCreateDevice; upnpControl.FindDeviceAsync("urn:schemas-upnp-org:device:HomeAutomationServer:1"); // Application.Current.ShutdownMode = System.Windows.ShutdownMode.OnLastWindowClose; var myDialogWindow = new LoadingDialog(); myDialogWindow.Show(); // Task loader = new Task(() => { int t = 0; while (t < 10) { if (upnpService.Count > 0) { Thread.Sleep(2000); for (int s = 0; s < UPnPDevices.Count; s++) { var dev = UPnPDevices.ElementAt(s).Value; if (dev.StandardDeviceType == "HomeAutomationServer") { System.Diagnostics.Process.Start(dev.PresentationURL); t = 10; break; } } } t++; Thread.Sleep(1000); } // Thread.Sleep(2000); // myDialogWindow.Dispatcher.BeginInvoke(new Action(() => { if (!createdNew) { myDialogWindow.Close(); Application.Current.Shutdown(); } else { var window = new MainWindow(); window.Show(); myDialogWindow.Close(); } }), null); }); loader.Start(); }
public UPnPInternalSmartControlPoint() { deviceFactory.OnDevice += new UPnPDeviceFactory.UPnPDeviceHandler(DeviceFactoryCreationSink); deviceFactory.OnFailed += new UPnPDeviceFactory.UPnPDeviceFailedHandler(DeviceFactoryFailedSink); deviceLifeTimeClock.OnExpired += new LifeTimeMonitor.LifeTimeHandler(DeviceLifeTimeClockSink); deviceUpdateClock.OnExpired += new LifeTimeMonitor.LifeTimeHandler(DeviceUpdateClockSink); hostNetworkInfo = new NetworkInfo(new NetworkInfo.InterfaceHandler(NetworkInfoNewInterfaceSink)); hostNetworkInfo.OnInterfaceDisabled += new NetworkInfo.InterfaceHandler(NetworkInfoOldInterfaceSink); // Launch a search for all devices and start populating the // internal smart control point device list. genericControlPoint = new UPnPControlPoint(); genericControlPoint.OnSearch += new UPnPControlPoint.SearchHandler(UPnPControlPointSearchSink); genericControlPoint.OnNotify += new SSDP.NotifyHandler(SSDPNotifySink); genericControlPoint.FindDeviceAsync("upnp:rootdevice"); }
public UPnPInternalSmartControlPoint() { deviceFactory.OnDevice += new UPnPDeviceFactory.UPnPDeviceHandler(DeviceFactoryCreationSink); deviceFactory.OnFailed += new UPnPDeviceFactory.UPnPDeviceFailedHandler(DeviceFactoryFailedSink); deviceLifeTimeClock.OnExpired += new LifeTimeMonitor.LifeTimeHandler(DeviceLifeTimeClockSink); deviceUpdateClock.OnExpired += new LifeTimeMonitor.LifeTimeHandler(DeviceUpdateClockSink); hostNetworkInfo = new NetworkInfo(new NetworkInfo.InterfaceHandler(NetworkInfoNewInterfaceSink)); hostNetworkInfo.OnInterfaceDisabled += new NetworkInfo.InterfaceHandler(NetworkInfoOldInterfaceSink); // Launch a search for all devices and start populating the // internal smart control point device list. genericControlPoint = new UPnPControlPoint(); genericControlPoint.OnSearch += new UPnPControlPoint.SearchHandler(UPnPControlPointSearchSink); genericControlPoint.OnNotify += new SSDP.NotifyHandler(SSDPNotifySink); genericControlPoint.FindDeviceAsync("upnp:rootdevice"); }