CancelAdvertisedName() public method

public CancelAdvertisedName ( string name, TransportMask transports ) : QStatus
name string
transports TransportMask
return QStatus
コード例 #1
0
		public void TestFoundLostAdvertisedName()
		{
			// create bus attachment
			AllJoyn.BusAttachment bus = new AllJoyn.BusAttachment("BusListenerTest", true);
			AllJoyn.QStatus status = AllJoyn.QStatus.FAIL;

			// start the bus attachment
			status = bus.Start();
			Assert.Equal(AllJoyn.QStatus.OK, status);

			// connect to the bus
			status = bus.Connect(AllJoynTestCommon.GetConnectSpec());
			Assert.Equal(AllJoyn.QStatus.OK, status);

			listenerRegistered = false;
			foundAdvertisedName = false;
			lostAdvertisedName = false;

			// register the bus listener
			AllJoyn.BusListener busListener = new TestBusListener(this);
			bus.RegisterBusListener(busListener);
			Wait(MaxWaitTime);
			Assert.Equal(true, listenerRegistered);

			// advertise the name, & see if we find it
			status = bus.FindAdvertisedName(ObjectName);
			Assert.Equal(AllJoyn.QStatus.OK, status);

			AllJoyn.SessionOpts sessionOpts = new AllJoyn.SessionOpts(
				AllJoyn.SessionOpts.TrafficType.Messages, false,
				AllJoyn.SessionOpts.ProximityType.Any, AllJoyn.TransportMask.Any);

			status = bus.AdvertiseName(ObjectName, sessionOpts.Transports);
			Assert.Equal(AllJoyn.QStatus.OK, status);

			Wait(MaxWaitTime);
			Assert.Equal(true, foundAdvertisedName);

			// stop advertising the name, & see if we lose it
			status = bus.CancelAdvertisedName(ObjectName, sessionOpts.Transports);
			Assert.Equal(AllJoyn.QStatus.OK, status);

			Wait(MaxWaitTime);
			Assert.Equal(true, lostAdvertisedName);

			// TODO: move these into a teardown method?
			busListener.Dispose();
			bus.Dispose();
		}
コード例 #2
0
		public void TestFoundNameByTransport()
		{
			// create bus attachment
			AllJoyn.BusAttachment bus = new AllJoyn.BusAttachment("BusListenerTest", true);
			AllJoyn.QStatus status = AllJoyn.QStatus.FAIL;

			// start the bus attachment
			status = bus.Start();
			Assert.Equal(AllJoyn.QStatus.OK, status);

			// connect to the bus
			status = bus.Connect(AllJoynTestCommon.GetConnectSpec());
			Assert.Equal(AllJoyn.QStatus.OK, status);

			listenerRegistered = false;
			foundAdvertisedName = false;
			nameOwnerChanged = false;
			transportFound = AllJoyn.TransportMask.None;

			// register the bus listener
			AllJoyn.BusListener busListener = new TestBusListener(this);
			bus.RegisterBusListener(busListener);
			Wait(MaxWaitTime);
			Assert.Equal(true, listenerRegistered);

			AllJoyn.SessionOpts sessionOpts = new AllJoyn.SessionOpts(
				AllJoyn.SessionOpts.TrafficType.Messages, false,
				AllJoyn.SessionOpts.ProximityType.Any, AllJoyn.TransportMask.Any);

			// advertise the name, & see if we find it
			status = bus.FindAdvertisedNameByTransport(ObjectName, AllJoyn.TransportMask.Local);
			Assert.Equal(AllJoyn.QStatus.OK, status);

			status = bus.AdvertiseName(ObjectName, sessionOpts.Transports);
			Assert.Equal(AllJoyn.QStatus.OK, status);

			Wait(MaxWaitTime);
			Assert.Equal(true, foundAdvertisedName);
			Assert.Equal(AllJoyn.TransportMask.Local, transportFound);

			status = bus.CancelAdvertisedName(ObjectName, sessionOpts.Transports);
			Assert.Equal(AllJoyn.QStatus.OK, status);

			status = bus.CancelFindAdvertisedNameByTransport(ObjectName, AllJoyn.TransportMask.Local);
			Assert.Equal(AllJoyn.QStatus.OK, status);

			foundAdvertisedName = false;
			status = bus.AdvertiseName(ObjectName, sessionOpts.Transports);
			Assert.Equal(AllJoyn.QStatus.OK, status);

			Wait(TimeSpan.FromSeconds(1));
			Assert.Equal(false, foundAdvertisedName);

			busListener.Dispose();
			bus.Dispose();
		}