本文整理汇总了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();
}
示例2: MainWindowViewModel
public MainWindowViewModel()
{
Lights = new ObservableCollection<Light>();
client = new Client();
client.ServiceAdded += client_ServiceAdded;
client.ServiceRemoved += client_ServiceRemoved;
client.BrowseAll();
}
示例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;
}
示例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.");
}
}
}
}
}
示例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.");
}
}
}
}
}
示例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.");
}
}
}
}
}
示例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.");
}
}
}
}
}