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


C# BusAttachment.CancelAdvertiseName方法代码示例

本文整理汇总了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();
        }
开发者ID:kalperin,项目名称:alljoyn_core,代码行数:32,代码来源:BusAttachmentTests.cs

示例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
        }
开发者ID:kalperin,项目名称:alljoyn_core,代码行数:60,代码来源:BusAttachmentTests.cs


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