protected override void FoundAdvertisedName(string name, AllJoyn.TransportMask transport, string namePrefix) { if (string.Compare(OBJECT_NAME, name) == 0) { _sessionTest.foundAdvertisedNameFlag = true; EventWaitHandle ewh = new EventWaitHandle(true, EventResetMode.AutoReset, "FoundAdvertisedName"); ewh.Set(); } }
protected override void FoundAdvertisedName(string name, AllJoyn.TransportMask transport, string namePrefix) { serverText += "Client FoundAdvertisedName(name=" + name + ", prefix=" + namePrefix + ")\n"; Debug.Log("Client FoundAdvertisedName(name=" + name + ", prefix=" + namePrefix + ")"); if (string.Compare(SERVICE_NAME, name) == 0) { ajNet.sFoundName = name; } }
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(); }
protected override void FoundAdvertisedName(string name, AllJoyn.TransportMask transport, string namePrefix) { //Debug.LogError("FoundAdvertisedName(name=" + name + ", prefix=" + namePrefix + ")"); if (string.Compare(myAdvertisedName, name) == 0) { //Debug.LogError("Ignoring my advertisement"); } else if (string.Compare(SERVICE_NAME, namePrefix) == 0) { //Debug.LogError("Bla"); sFoundName.Add(name); } }
protected override void FoundAdvertisedName(string name, AllJoyn.TransportMask transport, string namePrefix) { chatText = "Chat FoundAdvertisedName(name=" + name + ", prefix=" + namePrefix + ")\n" + chatText; Debug.Log("Chat FoundAdvertisedName(name=" + name + ", prefix=" + namePrefix + ")"); if (string.Compare(myAdvertisedName, name) == 0) { chatText = "Ignoring my advertisement\n" + chatText; Debug.Log("Ignoring my advertisement"); } else if (string.Compare(SERVICE_NAME, namePrefix) == 0) { sFoundName.Add(name); } }
protected override void FoundAdvertisedName(string name, AllJoyn.TransportMask transport, string namePrefix) { Console.WriteLine("FoundAdvertisedName(name=" + name + ", prefix=" + namePrefix + ")"); if (string.Compare(SERVICE_NAME, name) == 0) { // We found a remote bus that is advertising basic service's well-known name so connect to it AllJoyn.SessionOpts opts = new AllJoyn.SessionOpts(AllJoyn.SessionOpts.TrafficType.Messages, false, AllJoyn.SessionOpts.ProximityType.Any, AllJoyn.TransportMask.Any); AllJoyn.QStatus status = sMsgBus.JoinSession(name, SERVICE_PORT, null, out sSessionId, opts); if (status) { Console.WriteLine("JoinSession SUCCESS (Session id={0})", sSessionId); } else { Console.WriteLine("JoinSession failed (status={0})", status.ToString()); } } sJoinComplete = true; }
public void TestFoundNameByTransport() { listenerRegistered = false; foundAdvertisedName = false; nameOwnerChanged = false; transportFound = AllJoyn.TransportMask.None; // register the bus listener 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); }
protected override void LostAdvertisedName(string name, AllJoyn.TransportMask transport, string namePrefix) { _busListenerTest.lostAdvertisedName = true; Notify(); }
protected override void FoundAdvertisedName(string name, AllJoyn.TransportMask transport, string namePrefix) { _busListenerTest.transportFound |= transport; _busListenerTest.foundAdvertisedName = true; Notify(); }
protected override void LostAdvertisedName(string name, AllJoyn.TransportMask transport, string namePrefix) { chatText = "Chat LostAdvertisedName(name=" + name + ", prefix=" + namePrefix + ")\n" + chatText; Debug.Log("Chat LostAdvertisedName(name=" + name + ", prefix=" + namePrefix + ")"); sFoundName.Remove(name); }
protected override void LostAdvertisedName(string name, AllJoyn.TransportMask transport, string namePrefix) { //Debug.LogError("LostAdvertisedName(name=" + name + ", prefix=" + namePrefix + ")"); sFoundName.Remove(name); }