public static void Main(string[] args) { InitParams initParams = new InitParams { MsearchTimeSecs = 1, UseLoopbackNetworkAdapter = true }; using (Library lib = Library.Create(initParams)) { SubnetList subnetList = new SubnetList(); NetworkAdapter nif = subnetList.SubnetAt(0); uint subnet = nif.Subnet(); subnetList.Dispose(); lib.StartCombined(subnet); Console.Write("TestCpDeviceDvCs - starting\n"); DeviceBasic device = new DeviceBasic(); CpDeviceDv cpDevice = new CpDeviceDv(device.Device()); TestBasicCp cp = new TestBasicCp(cpDevice); cp.TestActions(); cp.TestSubscriptions(); cpDevice.RemoveRef(); device.Dispose(); Console.Write("TestCpDeviceDvCs - completed\n"); } }
public Runner() { iInitParams = new InitParams(); iInitParams.DvUpnpWebServerPort = 0; iInitParams.LogOutput = new MessageListener(Log); iInitParams.SubnetListChangedListener = new ChangedListener(SubnetListChanged); iInitParams.SubnetAddedListener = new NetworkAdapterListener(SubnetAdded); iInitParams.SubnetRemovedListener = new NetworkAdapterListener(SubnetRemoved); iInitParams.NetworkAdapterChangedListener = new NetworkAdapterListener(NetworkAdapterChanged); iLibrary = Library.Create(iInitParams); Library.SetDebugLevel(Library.DebugLevel.Trace); SubnetList subnetList = new SubnetList(); NetworkAdapter nif = subnetList.SubnetAt(0); uint subnet = nif.Subnet(); subnetList.Dispose(); iLibrary.StartCombined(subnet); }
public static void Main(string[] args) { InitParams initParams = new InitParams { MsearchTimeSecs = 1, UseLoopbackNetworkAdapter = true, DvUpnpWebServerPort = 0 }; using (Library lib = Library.Create(initParams)) { SubnetList subnetList = new SubnetList(); NetworkAdapter nif = subnetList.SubnetAt(0); uint subnet = nif.Subnet(); subnetList.Dispose(); lib.StartCombined(subnet); new Runner(); } }
public static void Main(string[] aArgs) { Console.WriteLine("TestPerformanceCpCs - starting"); InitParams initParams = new InitParams(); using (Library lib = Library.Create(initParams)) { SubnetList subnetList = new SubnetList(); NetworkAdapter nif = subnetList.SubnetAt(0); uint subnet = nif.Subnet(); subnetList.Dispose(); var deviceListFactory = new CpUpnpDeviceListFactory(lib.StartCp(subnet)); CpDevice device = null; Semaphore sem = new Semaphore(0, 1); var deviceList = deviceListFactory.CreateListServiceType("openhome.org", "TestBasic", 1, (aDeviceList, aDevice) => { if (device != null) { throw new Exception("Found more than one device. Giving up as test results will probably be invalid."); } device = aDevice; device.AddRef(); sem.Release(); }, (aDeviceList, aDevice) => { throw new Exception("ERROR: Device removed while test is running."); }); sem.WaitOne(); // actions Console.WriteLine(""); int[] threadCounts = { 1, 2, 4 }; foreach (int threadCount in threadCounts) { List <Thread> threads = new List <Thread>(); for (int i = 0; i < threadCount; i++) { threads.Add(new Thread(ActionThread)); } ThreadArgs threadArgs = new ThreadArgs(device, kTestDurationMs); for (int i = 0; i < threadCount; i++) { threads[i].Start(threadArgs); } for (int i = 0; i < threadCount; i++) { threads[i].Join(); } Console.WriteLine("Invoked {0} actions in {1}ms using {2} threads", threadArgs.Count, kTestDurationMs, threadCount); } // subscriptions Thread thread = new Thread(SubscriptionThread); ThreadArgs args = new ThreadArgs(device, kTestDurationMs); thread.Start(args); thread.Join(); Console.WriteLine("\nCompleted {0} subscriptions in {1}ms\n", args.Count, kTestDurationMs); device.RemoveRef(); deviceList.Dispose(); Console.WriteLine("\nTests complete. Press 'q' to exit."); while (Console.ReadKey(true).KeyChar != 'q') { ; } } }