예제 #1
0
        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
0
        public void ConnectAsyncTest()
        {
            BusAttachment bus = new BusAttachment("connect", true, 4);

            bus.Start();

            for (int i = 0; i < 5; i++)
            {
                bus.ConnectAsync(connectSpec).AsTask().Wait();
                Assert.IsTrue(bus.IsConnected());
                bus.DisconnectAsync(connectSpec).AsTask().Wait();
                Assert.IsFalse(bus.IsConnected());
            }
        }
예제 #3
0
        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();
        }
예제 #4
0
        public void ConnectAsyncTest()
        {
            BusAttachment bus = new BusAttachment("connect", true, 4);
            bus.Start();

            for (int i = 0; i < 5; i++)
            {
                bus.ConnectAsync(connectSpec).AsTask().Wait();
                Assert.IsTrue(bus.IsConnected());
                bus.DisconnectAsync(connectSpec).AsTask().Wait();
                Assert.IsFalse(bus.IsConnected());
            }
        }