本文整理汇总了C#中BusAttachment.CancelAdvertiseName方法的典型用法代码示例。如果您正苦于以下问题:C# BusAttachment.CancelAdvertiseName方法的具体用法?C# BusAttachment.CancelAdvertiseName怎么用?C# BusAttachment.CancelAdvertiseName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BusAttachment
的用法示例。
在下文中一共展示了BusAttachment.CancelAdvertiseName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RegisterBusListenerTest
public void RegisterBusListenerTest()
{
BusAttachment service = new BusAttachment("service", true, 4);
service.Start();
service.ConnectAsync(connectSpec).AsTask().Wait();
service.RequestName("org.alljoyn.service", (byte)RequestNameType.DBUS_NAME_DO_NOT_QUEUE);
service.BindSessionPort(78, new ushort[1], new SessionOpts(TrafficType.TRAFFIC_MESSAGES, false,
ProximityType.PROXIMITY_ANY, TransportMaskType.TRANSPORT_ANY), new SessionPortListener(service));
service.AdvertiseName("org.alljoyn.service", TransportMaskType.TRANSPORT_ANY);
BusAttachment bus = new BusAttachment("buslistenertest", true, 4);
BusListenerTest bl = new BusListenerTest(bus);
bus.RegisterBusListener(bl.bl);
listenerRegistered.WaitOne();
bus.Start();
bus.ConnectAsync(connectSpec).AsTask().Wait();
bus.RequestName("org.alljoyn.buslistener", (byte)RequestNameType.DBUS_NAME_DO_NOT_QUEUE);
nameOwnerChanged.WaitOne();
bus.FindAdvertisedName("org.alljoyn.service");
foundAdvertisedName.WaitOne();
service.CancelAdvertiseName("org.alljoyn.service", TransportMaskType.TRANSPORT_ANY);
lostAdvertisedName.WaitOne();
bus.CancelFindAdvertisedName("org.alljoyn.service");
bus.UnregisterBusListener(bl.bl);
listenerUnregistered.WaitOne();
bus.DisconnectAsync(connectSpec).AsTask().Wait();
// BUGBUG: Don't receive the BusDisconnected signal (this will wait indefinitely)
//busDisconnected.WaitOne();
bus.StopAsync().AsTask().Wait();
// BUGBUG: Don't receive the BusStopping signal (this will wait indefinitely)
//busStopping.WaitOne();
}
示例2: AdvertisingTest
public void AdvertisingTest()
{
BusAttachment bus = new BusAttachment("advertise", true, 4);
bus.Start();
bus.ConnectAsync(connectSpec).AsTask().Wait();
BusAttachment clientConsumer = new BusAttachment("clientConsumer", true, 4);
AdvertiseBusListener bl = new AdvertiseBusListener(clientConsumer);
clientConsumer.Start();
clientConsumer.ConnectAsync(connectSpec).AsTask().Wait();
clientConsumer.FindAdvertisedName("org.alljoyn.one");
clientConsumer.FindAdvertisedName("org.alljoyn.two");
clientConsumer.FindAdvertisedName("org.alljoyn.three");
clientConsumer.FindAdvertisedName("org.alljoyn.four");
byte flags = (byte)RequestNameType.DBUS_NAME_DO_NOT_QUEUE;
string name1 = "org.alljoyn.one";
string name2 = "org.alljoyn.two";
string name3 = "org.alljoyn.three";
string name4 = "org.alljoyn.four";
bus.RequestName(name1, flags);
bus.RequestName(name2, flags);
bus.RequestName(name3, flags);
bus.RequestName(name4, flags);
bus.AdvertiseName(name1, TransportMaskType.TRANSPORT_ANY);
bus.AdvertiseName(name2, TransportMaskType.TRANSPORT_ANY);
bus.AdvertiseName(name3, TransportMaskType.TRANSPORT_ANY);
bus.AdvertiseName(name4, TransportMaskType.TRANSPORT_ANY);
gotAllNames.WaitOne();
lock (bl.FoundNames)
{
Assert.IsTrue(bl.FoundNames.Contains(name1));
Assert.IsTrue(bl.FoundNames.Contains(name2));
Assert.IsTrue(bl.FoundNames.Contains(name3));
Assert.IsTrue(bl.FoundNames.Contains(name4));
}
gotAllNames.Reset();
bus.CancelAdvertiseName(name1, TransportMaskType.TRANSPORT_ANY);
bus.CancelAdvertiseName(name2, TransportMaskType.TRANSPORT_ANY);
bus.CancelAdvertiseName(name3, TransportMaskType.TRANSPORT_ANY);
bus.CancelAdvertiseName(name4, TransportMaskType.TRANSPORT_ANY);
gotAllNames.WaitOne();
lock (bl.LostNames)
{
Assert.IsTrue(bl.LostNames.Contains(name1));
Assert.IsTrue(bl.LostNames.Contains(name2));
Assert.IsTrue(bl.LostNames.Contains(name3));
Assert.IsTrue(bl.LostNames.Contains(name4));
}
// TODO: Make sure we're not still receiving advertisements for the names
}