Initialisation options
Most options apply equally to Control Point and Device stacks. Any functions that are specific to a particular stack include either 'Cp' or 'Dv'
コード例 #1
0
        /// <summary>
        /// Create the library instance.
        /// </summary>
        /// <remarks>Only one instance per process is allowed.
        /// This must be called before any other library function.</remarks>
        public static Library Create(InitParams aParams)
        {
            Library instance = new Library();

            instance.Initialise(aParams);
            return(instance);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: weeble/ohos
        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;
        }
コード例 #3
0
        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");
            }
        }
コード例 #4
0
ファイル: TestProxy.cs プロジェクト: wifigeek/ohNet
 public static void Main(string[] args)
 {
     Core.InitParams initParams = new Core.InitParams();
     Core.Library lib = new Core.Library();
     lib.Initialise(initParams);
     lib.StartCp();
     new Runner((int)initParams.MsearchTimeSecs);
     lib.Close();
 }
コード例 #5
0
ファイル: TestPerformanceDv.cs プロジェクト: sewood/ohNet
 public static void Main(string[] args)
 {
     Console.WriteLine("TestPerformanceDvCs - starting ('q' to quit)");
     InitParams initParams = new InitParams();
     using (Library lib = Library.Create(initParams))
     {
         lib.StartDv();
         DeviceBasic device = new DeviceBasic();
         while (Console.ReadKey(true).KeyChar != 'q') ;
         device.Dispose();
     }
 }
コード例 #6
0
ファイル: TestDvDevice.cs プロジェクト: wifigeek/ohNet
 public static void Main(string[] args)
 {
     InitParams initParams = new InitParams
     {
         MsearchTimeSecs = 1,
         UseLoopbackNetworkInterface = true
     };
     Library lib = new Library();
     lib.Initialise(initParams);
     lib.StartCombined();
     new Runner();
     lib.Close();
 }
コード例 #7
0
ファイル: TestProxy.cs プロジェクト: simoncn/ohNet
 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);
     }
 }
コード例 #8
0
ファイル: TestProxy.cs プロジェクト: sewood/ohNet
 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);
     }
 }
コード例 #9
0
ファイル: TestDvLights.cs プロジェクト: broonie/ohNet
 public static void Main(string[] args)
 {
     // !!!! add OptionParser class rather than relying on the user guessing that the first arg
     // is an int 1..3 and the second is the path of a folder that'll serve a test UI
     Core.InitParams initParams = new Core.InitParams();
     using (Core.Library lib = Core.Library.Create(initParams))
     {
         lib.StartDv();
         Console.Write("TestDvLights - starting\n");
         DeviceLights device  = new DeviceLights(Convert.ToInt32(args[0]), args[1]);
         Semaphore    blocker = new Semaphore(0, 1);
         blocker.WaitOne(60 * 60 * 1000); // make the device available for 1 hour then assume we've been forgotten about and exit
         device.Dispose();
         Console.Write("TestDvLights - exiting\n");
     }
 }
コード例 #10
0
ファイル: TestAdapterChange.cs プロジェクト: Wodath/ohNet
 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);
 }
コード例 #11
0
 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();
     }
 }
コード例 #12
0
ファイル: OhNet.cs プロジェクト: broonie/ohNet
        private void Initialise(InitParams aParams)
        {
            iLogOutput                     = aParams.LogOutput;
            iFatalErrorHandler             = aParams.FatalErrorHandler;
            iAsyncBeginHandler             = aParams.AsyncBeginHandler;
            iAsyncEndHandler               = aParams.AsyncEndHandler;
            iAsyncErrorHandler             = aParams.AsyncErrorHandler;
            iSubnetListChangedListener     = aParams.SubnetListChangedListener;
            iSubnetAddedListener           = aParams.SubnetAddedListener;
            iSubnetRemovedListener         = aParams.SubnetRemovedListener;
            iNetworkAdapterChangedListener = aParams.NetworkAdapterChangedListener;
            IntPtr nativeInitParams = aParams.AllocNativeInitParams(IntPtr.Zero);

            OhNetInitParamsSetFreeExternalCallback(nativeInitParams, FreeMemory);
            if (0 != OhNetLibraryInitialise(nativeInitParams))
            {
                InitParams.FreeNativeInitParams(nativeInitParams);
                throw new LibraryException();
            }
        }
コード例 #13
0
ファイル: TestCpDeviceDv.cs プロジェクト: wifigeek/ohNet
        public static void Main(string[] args)
        {
            InitParams initParams = new InitParams
            {
                MsearchTimeSecs = 1,
                UseLoopbackNetworkInterface = true
            };
            Library lib = new Library();
            lib.Initialise(initParams);
            lib.StartCombined();

            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");

            lib.Close();
        }
コード例 #14
0
ファイル: UPNPWrapper.cs プロジェクト: stoennies/raumwiese
        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);
        }
コード例 #15
0
ファイル: OhNet.cs プロジェクト: kevin5391/ohNet
 private Library(InitParams aParams)
 {
     iInitParams = aParams;
 }
コード例 #16
0
ファイル: OhNet.cs プロジェクト: astaykov/ohNet
 public ChangedListener(InitParams.ChangeHandler aHandler)
 {
     iHandler = aHandler;
 }
コード例 #17
0
ファイル: OhNet.cs プロジェクト: astaykov/ohNet
 public NetworkAdapterListener(InitParams.NetworkAdapterHandler aHandler)
 {
     iHandler = aHandler;
 }
コード例 #18
0
ファイル: OhNet.cs プロジェクト: astaykov/ohNet
 public MessageListener(InitParams.MessageHandler aHandler)
 {
     iHandler = aHandler;
 }
コード例 #19
0
ファイル: OhNet.cs プロジェクト: astaykov/ohNet
 public AsyncListener(InitParams.AsyncHandler aHandler)
 {
     iHandler = aHandler;
 }
コード例 #20
0
ファイル: TestDvLights.cs プロジェクト: nterry/ohNet
 public static void Main(string[] args)
 {
     // !!!! add OptionParser class rather than relying on the user guessing that the first arg
     // is an int 1..3 and the second is the path of a folder that'll serve a test UI
     Core.InitParams initParams = new Core.InitParams();
     using (Core.Library lib = Core.Library.Create(initParams))
     {
         lib.StartDv();
         Console.Write("TestDvLights - starting\n");
         DeviceLights device = new DeviceLights(Convert.ToInt32(args[0]), args[1]);
         Semaphore blocker = new Semaphore(0, 1);
         blocker.WaitOne(60 * 60 * 1000); // make the device available for 1 hour then assume we've been forgotten about and exit
         device.Dispose();
         Console.Write("TestDvLights - exiting\n");
     }
 }
コード例 #21
0
ファイル: OhNet.cs プロジェクト: chinshou/ohNet
 private void Initialise(InitParams aParams)
 {
     iLogOutput = aParams.LogOutput;
     iFatalErrorHandler = aParams.FatalErrorHandler;
     iAsyncBeginHandler = aParams.AsyncBeginHandler;
     iAsyncEndHandler = aParams.AsyncEndHandler;
     iAsyncErrorHandler = aParams.AsyncErrorHandler;
     iSubnetListChangedListener = aParams.SubnetListChangedListener;
     iSubnetAddedListener = aParams.SubnetAddedListener;
     iSubnetRemovedListener = aParams.SubnetRemovedListener;
     iNetworkAdapterChangedListener = aParams.NetworkAdapterChangedListener;
     IntPtr nativeInitParams = aParams.AllocNativeInitParams(IntPtr.Zero);
     OhNetInitParamsSetFreeExternalCallback(nativeInitParams, FreeMemory);
     if (0 != OhNetLibraryInitialise(nativeInitParams))
     {
         InitParams.FreeNativeInitParams(nativeInitParams);
         throw new LibraryException();
     }
 }
コード例 #22
0
ファイル: OhNet.cs プロジェクト: chinshou/ohNet
 public NetworkAdapterListener(InitParams.NetworkAdapterHandler aHandler)
 {
     iHandler = aHandler;
     Callback = new InitParams.OhNetCallbackNetworkAdapter(NetworkAdapter);
 }
コード例 #23
0
ファイル: OhNet.cs プロジェクト: chinshou/ohNet
 public ChangedListener(InitParams.ChangeHandler aHandler)
 {
     iHandler = aHandler;
     Callback = new InitParams.OhNetCallback(Changed);
 }
コード例 #24
0
ファイル: OhNet.cs プロジェクト: chinshou/ohNet
 /// <summary>
 /// Create the library instance.
 /// </summary>
 /// <remarks>Only one instance per process is allowed.
 /// This must be called before any other library function.</remarks>
 public static Library Create(InitParams aParams)
 {
     Library instance = new Library();
     instance.Initialise(aParams);
     return instance;
 }
コード例 #25
0
ファイル: OhNet.cs プロジェクト: hacx/ohNet
 private void Initialise(InitParams aParams)
 {
     IntPtr nativeInitParams = aParams.AllocNativeInitParams(IntPtr.Zero);
     iCallbackFreeMemory = new CallbackFreeMemory(FreeMemory);
     OhNetInitParamsSetFreeExternalCallback(nativeInitParams, iCallbackFreeMemory);
     if (0 != OhNetLibraryInitialise(nativeInitParams))
     {
         InitParams.FreeNativeInitParams(nativeInitParams);
         throw new LibraryException();
     }
 }
コード例 #26
0
ファイル: OhNet.cs プロジェクト: chinshou/ohNet
 public MessageListener(InitParams.MessageHandler aHandler)
 {
     iHandler = aHandler;
     Callback = new InitParams.OhNetCallbackMsg(Message);
 }
コード例 #27
0
 private Library(InitParams aParams)
 {
     iInitParams = aParams;
 }
コード例 #28
0
ファイル: OhNet.cs プロジェクト: chinshou/ohNet
 public AsyncListener(InitParams.AsyncHandler aHandler)
 {
     iHandler = aHandler;
     Callback = new InitParams.OhNetCallbackAsync(AsyncListenerCallback);
 }
コード例 #29
0
ファイル: TestPerformanceCp.cs プロジェクト: openhome/ohNet
        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') ;
            }
        }