当前位置: 首页>>代码示例>>C#>>正文


C# Client.BrowseAll方法代码示例

本文整理汇总了C#中Client.BrowseAll方法的典型用法代码示例。如果您正苦于以下问题:C# Client.BrowseAll方法的具体用法?C# Client.BrowseAll怎么用?C# Client.BrowseAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Client的用法示例。


在下文中一共展示了Client.BrowseAll方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Search

        public void Search()
        {
            Console.WriteLine("Launching search.");
            var list = new List<DeviceAnnouncement>();

            using (var client = new Client())
            {
                client.BrowseAll();
                client.DeviceAdded += (sender, args) =>
                {
                    list.Add(args.Device);
                };

                Thread.Sleep(TimeSpan.FromSeconds(5));
            }

            Console.WriteLine($"Search completed. Found {list.Count} devices.");

            foreach (var announcement in list)
            {
                OnDeviceDetected(announcement);
            }

            _provider.DisableOldDevices();
        }
开发者ID:Silvenga,项目名称:Slight.WeMo,代码行数:25,代码来源:DiscovererTask.cs

示例2: MainWindowViewModel

        public MainWindowViewModel()
        {
            Lights = new ObservableCollection<Light>();

            client = new Client();
            client.ServiceAdded += client_ServiceAdded;
            client.ServiceRemoved += client_ServiceRemoved;
            client.BrowseAll();
        }
开发者ID:wasabii,项目名称:mono-upnp,代码行数:9,代码来源:MainWindowViewModel.cs

示例3: StartClient

        void StartClient ()
        {
            client = new Client ();
            client.DeviceAdded += OnDeviceAdded;
            client.DeviceRemoved += OnDeviceRemoved;
            try {
                client.BrowseAll ();
            } catch (Exception ex) {
                Console.WriteLine ("Error starting Mono.Upnp service browser: {0}", ex.Message);
                return;
            }

            client_running = true;
        }
开发者ID:pacificIT,项目名称:mono-upnp,代码行数:14,代码来源:UpnpServiceWidget.cs

示例4: BrowseAllSearchTest

 public void BrowseAllSearchTest ()
 {
     using (var client = new Client ()) {
         using (var server = new Server ()) {
             server.Announce ("upnp:test", "uuid:mono-upnp-tests:test", "http://localhost/");
             client.ServiceAdded += ClientServiceAdded;
             lock (mutex) {
                 client.BrowseAll ();
                 if (!Monitor.Wait (mutex, TimeSpan.FromSeconds (30))) {
                     Assert.Fail ("The announcement timed out.");
                 }
             }
         }
     }
 }
开发者ID:pacificIT,项目名称:mono-upnp,代码行数:15,代码来源:ClientTests.cs

示例5: AnnouncementTest

 public void AnnouncementTest ()
 {
     using (var server = new Server (CreateRoot ())) {
         using (var client = new Client ()) {
             client.DeviceAdded += AnnouncementTestClientDeviceAdded;
             client.ServiceAdded += AnnouncementTestClientServiceAdded;
             client.BrowseAll ();
             lock (mutex) {
                 flag = false;
                 server.Start ();
                 if (!Monitor.Wait (mutex, TimeSpan.FromSeconds (30))) {
                     Assert.Fail ("The UPnP server announcement timed out.");
                 }
             }
         }
     }
 }
开发者ID:rsweeney21,项目名称:Mono.Upnp,代码行数:17,代码来源:ClientTests.cs

示例6: GetServiceControllerTest

 public void GetServiceControllerTest ()
 {
     using (var server = new Server (CreateRoot ())) {
         using (var client = new Client ()) {
             client.BrowseAll ();
             client.ServiceAdded += (obj, args) => {
                 lock (mutex) {
                     try {
                         var controller = args.Service.GetService ().GetController ();
                         Assert.IsNotNull (controller);
                     } finally {
                         Monitor.Pulse (mutex);
                     }
                 }
             };
             lock (mutex) {
                 server.Start ();
                 if (!Monitor.Wait (mutex, TimeSpan.FromSeconds (30))) {
                     Assert.Fail ("The UPnP server announcement timed out.");
                 }
             }
         }
     }
 }
开发者ID:rsweeney21,项目名称:Mono.Upnp,代码行数:24,代码来源:ClientTests.cs

示例7: GetServiceTest

 public void GetServiceTest ()
 {
     using (var server = new Server (CreateRoot ())) {
         using (var client = new Client ()) {
             client.BrowseAll ();
             client.ServiceAdded += (obj, args) => {
                 lock (mutex) {
                     var service = args.Service.GetService ();
                     Assert.AreEqual ("urn:upnp-org:serviceId:testService1", service.Id);
                     Monitor.Pulse (mutex);
                 }
             };
             lock (mutex) {
                 server.Start ();
                 if (!Monitor.Wait (mutex, TimeSpan.FromSeconds (30))) {
                     Assert.Fail ("The UPnP server announcement timed out.");
                 }
             }
         }
     }
 }
开发者ID:rsweeney21,项目名称:Mono.Upnp,代码行数:21,代码来源:ClientTests.cs


注:本文中的Client.BrowseAll方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。