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"); } }
static int Main() { BasicConfigurator.Configure(); InitParams initParams = new InitParams {UseLoopbackNetworkAdapter = true}; string nodeGuid = Guid.NewGuid().ToString(); using (Library library = Library.Create(initParams)) { SubnetList subnetList = new SubnetList(); NetworkAdapter nif = subnetList.SubnetAt(0); uint subnet = nif.Subnet(); subnetList.Dispose(); var combinedStack = library.StartCombined(subnet); AppServices services = new AppServices { NodeRebooter = new NullNodeRebooter(), DeviceFactory = new DvDeviceFactory(combinedStack.DeviceStack) }; string exePath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); string storePath = Path.Combine(exePath, "test-store"); ConfigFileCollection config = new ConfigFileCollection(new string[] { }); config.AddFile("config.xml", new XElement("ohos", new XElement("system-settings", new XElement("store", storePath) ) ) ); if (Directory.Exists(storePath)) { Directory.Delete(storePath, true); } using (var installModule = new AppShellModule(services, config, null, nodeGuid)) { installModule.AppShell.Start(); installModule.AppShell.Install(Path.Combine(exePath, "ohOs.TestApp1.zip")); List<AppInfo> apps = installModule.AppShell.GetApps().ToList(); if (apps.Count!=1) { Console.Error.WriteLine("There should be one app installed. (Found {0}.)", apps.Count); return 1; } if (apps[0].Name!="ohOs.TestApp1") { Console.Error.WriteLine("Wrong app name. (Got '{0}'.)", apps[0].Name); PrintAppState(apps[0]); return 1; } if (apps[0].State!=AppState.Running) { Console.Error.WriteLine("App should be running. (It isn't.)"); PrintAppState(apps[0]); return 1; } } } return 0; }
public static void Main(string[] args) { Core.InitParams initParams = new Core.InitParams(); using (Core.Library lib = Core.Library.Create(initParams)) { Core.SubnetList subnetList = new Core.SubnetList(); Core.NetworkAdapter nif = subnetList.SubnetAt(0); uint subnet = nif.Subnet(); Console.WriteLine("Using adapter: {0}", nif.Name()); subnetList.Dispose(); lib.StartCp(subnet); new Runner((int)initParams.MsearchTimeSecs); } }
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)); ICpDevice 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') ; } }
public override void init() { mh = new InitParams.MessageHandler(mhCb); ml = new MessageListener(mh); OpenHome.Net.Core.InitParams initParams = new OpenHome.Net.Core.InitParams(); OpenHome.Net.Core.Library.SetDebugLevel(Library.DebugLevel.Error); initParams.LogOutput = ml; lib = OpenHome.Net.Core.Library.Create(initParams); OpenHome.Net.Core.SubnetList subnetList = new OpenHome.Net.Core.SubnetList(); OpenHome.Net.Core.NetworkAdapter nif = subnetList.SubnetAt((uint)networkConnectInfo.subNetIndex); this.delegateStartingNetwork(nif.FullName()); uint subnet = nif.Subnet(); subnetList.Dispose(); lib.StartCp(subnet); }