public Runner() { Console.Write("TestDvDeviceCs - starting\n"); DeviceBasic device = new DeviceBasic(); iDeviceList = new List <CpDevice>(); CpDeviceList.ChangeHandler added = new CpDeviceList.ChangeHandler(DeviceAdded); CpDeviceList.ChangeHandler removed = new CpDeviceList.ChangeHandler(DeviceRemoved); CpDeviceListUpnpServiceType list = new CpDeviceListUpnpServiceType("openhome.org", "TestBasic", 1, added, removed); Semaphore sem = new Semaphore(0, 1); sem.WaitOne(1000); Debug.Assert(iDeviceList.Count == 1); TestBasicCp cp = new TestBasicCp(iDeviceList[0]); cp.TestActions(); cp.TestSubscriptions(); list.Dispose(); lock (this) { for (int i = 0; i < iDeviceList.Count; i++) { iDeviceList[i].RemoveRef(); } } device.Dispose(); Console.Write("TestDvDeviceCs - completed\n"); }
public Runner() { Console.Write("TestDvDeviceCs - starting\n"); DeviceBasic device = new DeviceBasic(); iDeviceList = new List<CpDevice>(); CpDeviceList.ChangeHandler added = new CpDeviceList.ChangeHandler(DeviceAdded); CpDeviceList.ChangeHandler removed = new CpDeviceList.ChangeHandler(DeviceRemoved); CpDeviceListUpnpServiceType list = new CpDeviceListUpnpServiceType("openhome.org", "TestBasic", 1, added, removed); Semaphore sem = new Semaphore(0, 1); sem.WaitOne(1000); Debug.Assert(iDeviceList.Count == 1); TestBasicCp cp = new TestBasicCp(iDeviceList[0]); cp.TestActions(); cp.TestSubscriptions(); list.Dispose(); lock (this) { for (int i = 0; i < iDeviceList.Count; i++) { iDeviceList[i].RemoveRef(); } } device.Dispose(); Console.Write("TestDvDeviceCs - completed\n"); }
/// <summary> /// Create a device list that detects a UPnP devices with a specific Udn. /// </summary> /// <param name="aUuid">Unique identifier for the target device.</param> /// <param name="aAdded">Delegate which will be run when a new device is detected. /// Clients who are interested this new device should call AddRef() on it and add it to some local collection. /// This callback will never be run for a device that is already in the list.</param> /// <param name="aRemoved">Delegatewhich will be run when a device is removed from the network. /// Clients who had previously stored a reference to the device in their aAdded callback should call RemoveRef() /// and remove the device from their local collection. /// Clients who had not previously claimed a reference to a device must not call ReleaseRef().</param> public ICpDeviceList CreateListUuid( string aUuid, CpDeviceList.ChangeHandler aAdded, CpDeviceList.ChangeHandler aRemoved) { return(new CpDeviceListUpnpUuid(aUuid, aAdded, aRemoved)); }
/// <summary> /// Create a device list that detects UPnP devices bearing a specific type of service. /// </summary> /// <param name="aDomain">Vendor domain for the target service (e.g. upnp.org).</param> /// <param name="aServiceType">Name of the target service.</param> /// <param name="aVersion">Version number for the target service.</param> /// <param name="aAdded">Delegate which will be run when a new device is detected. /// Clients who are interested this new device should call AddRef() on it and add it to some local collection. /// This callback will never be run for a device that is already in the list.</param> /// <param name="aRemoved">Delegatewhich will be run when a device is removed from the network. /// Clients who had previously stored a reference to the device in their aAdded callback should call RemoveRef() /// and remove the device from their local collection. /// Clients who had not previously claimed a reference to a device must not call ReleaseRef().</param> public ICpDeviceList CreateListServiceType( string aDomain, string aServiceType, uint aVersion, CpDeviceList.ChangeHandler aAdded, CpDeviceList.ChangeHandler aRemoved) { return(new CpDeviceListUpnpServiceType(aDomain, aServiceType, aVersion, aAdded, aRemoved)); }
public Runner() { iDeviceList = new List <CpDevice>(); CpDeviceList.ChangeHandler added = new CpDeviceList.ChangeHandler(DeviceAdded); CpDeviceList.ChangeHandler removed = new CpDeviceList.ChangeHandler(DeviceRemoved); CpDeviceListUpnpServiceType list = new CpDeviceListUpnpServiceType("upnp.org", "ConnectionManager", 1, added, removed); //CpDeviceListUpnpUuid list = new CpDeviceListUpnpUuid("896659847466-a4badbeaacbc-737837", added, removed); Semaphore sem = new Semaphore(0, 1); sem.WaitOne(6000); InvokeSync(); // Note that following tests handle the device list changing (i.e. devices being switched on/off) badly Console.Write("\n\n"); int count = iDeviceList.Count; DateTime startTime = DateTime.Now; PollInvoke(); DateTime endTime = DateTime.Now; uint avgActions = 0; if (count > 0) { avgActions = (uint)(iActionCount / count); } double secs = endTime.Subtract(startTime).TotalSeconds; Console.Write("\n" + iActionCount + " actions invoked on " + count + " devices (avg " + avgActions + ") in " + secs + " seconds\n\n"); Console.Write("\n\n"); startTime = DateTime.Now; PollSubscribe(); endTime = DateTime.Now; uint avgSubscriptions = 0; if (count > 0) { avgSubscriptions = (uint)(iSubscriptionCount / count); } secs = endTime.Subtract(startTime).TotalSeconds; Console.Write("\n" + iSubscriptionCount + " subscriptions on " + count + " devices (avg " + avgSubscriptions + ") in " + secs + " seconds\n\n"); list.Dispose(); Console.Write("Tests completed\n"); }
public Runner() { Console.Write("TestDvDeviceCpp - starting\n"); iUpdatesComplete = new Semaphore(0, Int32.MaxValue); iSingleChanged = new Semaphore(0, Int32.MaxValue); DeviceBasic device = new DeviceBasic(); iDeviceList = new List <CpDevice>(); CpDeviceList.ChangeHandler added = new CpDeviceList.ChangeHandler(DeviceAdded); CpDeviceList.ChangeHandler removed = new CpDeviceList.ChangeHandler(DeviceRemoved); CpDeviceListUpnpServiceType list = new CpDeviceListUpnpServiceType("zapp.org", "TestBasic", 1, added, removed); Semaphore sem = new Semaphore(0, 1); sem.WaitOne(1000); TestActions(); TestSubscriptions(); list.Dispose(); device.Dispose(); Console.Write("TestDvDeviceCpp - completed\n"); }
/// <summary> /// Create a device list that detects all UPnP root devices. /// </summary> /// <param name="aAdded">Delegate which will be run when a new device is detected. /// Clients who are interested this new device should call AddRef() on it and add it to some local collection. /// This callback will never be run for a device that is already in the list.</param> /// <param name="aRemoved">Delegatewhich will be run when a device is removed from the network. /// Clients who had previously stored a reference to the device in their aAdded callback should call RemoveRef() /// and remove the device from their local collection. /// Clients who had not previously claimed a reference to a device must not call ReleaseRef().</param> public ICpDeviceList CreateListRoot( CpDeviceList.ChangeHandler aAdded, CpDeviceList.ChangeHandler aRemoved) { return(new CpDeviceListUpnpRoot(aAdded, aRemoved)); }