/** * Dispose the BusListener * @param disposing describes if its activly being disposed */ protected virtual void Dispose(bool disposing) { if (!_isDisposed) { // Dispose of BusAttachment before listeners if (_registeredBus != null) { _registeredBus.Dispose(); } Thread destroyThread = new Thread((object o) => { alljoyn_buslistener_destroy(_busListener); }); destroyThread.Start(); while (destroyThread.IsAlive) { AllJoyn.TriggerCallbacks(); Thread.Sleep(0); } _busListener = IntPtr.Zero; main.Free(); } _isDisposed = true; }
protected virtual void Dispose(bool disposing) { if (!_isDisposed) { Thread destroyThread = new Thread((object o) => { alljoyn_busobject_destroy(_busObject); }); destroyThread.Start(); while (destroyThread.IsAlive) { AllJoyn.TriggerCallbacks(); Thread.Sleep(0); } _busObject = IntPtr.Zero; } _isDisposed = true; }
public QStatus UnbindSessionPort(ushort sessionPort) { QStatus ret = QStatus.OK; Thread bindThread = new Thread((object o) => { ret = alljoyn_busattachment_unbindsessionport(_busAttachment, sessionPort); }); bindThread.Start(); while (bindThread.IsAlive) { AllJoyn.TriggerCallbacks(); Thread.Sleep(0); } return(ret); }
public QStatus BindSessionPort(ref ushort sessionPort, SessionOpts opts, SessionPortListener listener) { QStatus ret = QStatus.OK; ushort otherSessionPort = sessionPort; Thread bindThread = new Thread((object o) => { ret = alljoyn_busattachment_bindsessionport(_busAttachment, ref otherSessionPort, opts.UnmanagedPtr, listener.UnmanagedPtr); }); bindThread.Start(); while (bindThread.IsAlive) { AllJoyn.TriggerCallbacks(); Thread.Sleep(0); } sessionPort = otherSessionPort; return(ret); }
public QStatus JoinSession(string sessionHost, ushort sessionPort, SessionListener listener, out uint sessionId, SessionOpts opts) { IntPtr optsPtr = opts.UnmanagedPtr; uint sessionId_out = 0; int qstatus = 0; Thread joinSessionThread = new Thread((object o) => { qstatus = alljoyn_busattachment_joinsession(_busAttachment, sessionHost, sessionPort, (listener == null ? IntPtr.Zero : listener.UnmanagedPtr), ref sessionId_out, optsPtr); }); joinSessionThread.Start(); while (joinSessionThread.IsAlive) { AllJoyn.TriggerCallbacks(); Thread.Sleep(1); } sessionId = sessionId_out; return(qstatus); }
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 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) { 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 bool VerifyCredentials(string authMechanism, string peerName, AllJoyn.Credentials credentials) { _authListenerTest.authflags.verifyCreds_client = true; return true; }
protected override void SecurityViolation(AllJoyn.QStatus status, AllJoyn.Message msg) { _authListenerTest.authflags.securityViolation_service = true; }
protected override bool RequestCredentials(string authMechanism, string peerName, ushort authCount, string userName, AllJoyn.Credentials.CredentialFlags credMask, AllJoyn.Credentials credentials) { if ((credMask & AllJoyn.Credentials.CredentialFlags.Password) == AllJoyn.Credentials.CredentialFlags.Password) { credentials.Password = "******"; } _authListenerTest.authflags.requestCreds_client = true; return true; }
protected override bool VerifyCredentials(string authMechanism, string peerName, AllJoyn.Credentials credentials) { _objectSecurityTest.authflags.verifyCreds_service = true; return true; }
protected override bool RequestCredentials(string authMechanism, string peerName, ushort authCount, string userName, AllJoyn.Credentials.CredentialFlags credMask, AllJoyn.Credentials credentials) { if ((credMask & AllJoyn.Credentials.CredentialFlags.Password) == AllJoyn.Credentials.CredentialFlags.Password) { credentials.Password = "******"; } _objectSecurityTest.authflags.requestCreds_service = true; return true; }
protected override void SecurityViolation(AllJoyn.QStatus status, AllJoyn.Message msg) { _objectSecurityTest.authflags.securityViolation_client = true; }
public TestBusObject(AllJoyn.BusAttachment bus, string path) : base(path, false) { AllJoyn.InterfaceDescription testIntf = bus.GetInterface("org.alljoyn.test.BusAttachment"); AllJoyn.QStatus status = AddInterface(testIntf); Assert.Equal(AllJoyn.QStatus.OK, status); testSignalMember = testIntf.GetMember("testSignal"); }
protected override void FoundAdvertisedName(string name, AllJoyn.TransportMask transport, string namePrefix) { Debug.Log("Client 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) { Debug.Log("Client JoinSession SUCCESS (Session id=" + sSessionId + ")"); } else { Debug.Log("Client JoinSession failed (status=" + status.ToString() + ")"); } } sJoinComplete = true; }
protected override bool RequestCredentials(string authMechanism, string peerName, ushort authCount, string userName, AllJoyn.Credentials.CredentialFlags credMask, AllJoyn.Credentials credentials) { if (userName != "Mr. Cuddles") { return false; } else if ((credMask & AllJoyn.Credentials.CredentialFlags.Password) == AllJoyn.Credentials.CredentialFlags.Password) { credentials.Password = "******"; } else { return false; } _authListenerTest.authflags.requestCreds_service = true; return true; }
protected override void ListenerRegistered(AllJoyn.BusAttachment busAttachment) { _concurrentCallbackTest.listenerRegisteredFlag = true; Notify(); }
protected override bool RequestCredentials(string authMechanism, string peerName, ushort authCount, string userName, AllJoyn.Credentials.CredentialFlags credMask, AllJoyn.Credentials credentials) { if ((credMask & AllJoyn.Credentials.CredentialFlags.CertChain) == AllJoyn.Credentials.CredentialFlags.CertChain) { credentials.CertChain = client_x509cert; } if ((credMask & AllJoyn.Credentials.CredentialFlags.PrivateKey) == AllJoyn.Credentials.CredentialFlags.PrivateKey) { credentials.PrivateKey = client_privKey; } if ((credMask & AllJoyn.Credentials.CredentialFlags.Password) == AllJoyn.Credentials.CredentialFlags.Password) { credentials.Password = "******"; } _authListenerTest.authflags.requestCreds_client = true; return true; }
public AllJoyn.QStatus SendTestSignal(string destination, uint sessionId, AllJoyn.InterfaceDescription.Member member, AllJoyn.MsgArg args, ushort timeToLife, byte flags, AllJoyn.Message msg) { return Signal(destination, sessionId, member, args, timeToLife, flags, msg); }
protected override bool RequestCredentials(string authMechanism, string peerName, ushort authCount, string userName, AllJoyn.Credentials.CredentialFlags credMask, AllJoyn.Credentials credentials) { _authListenerTest.authflags.requestCreds_client = true; return false; }
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 SecurityViolation(AllJoyn.QStatus status, AllJoyn.Message msg) { _authListenerTest.authflags.securityViolation_client = true; _authListenerTest.Notify(); }
public TestBusObject(AllJoyn.BusAttachment bus, string path) : base(bus, path, false) { AllJoyn.InterfaceDescription exampleIntf = bus.GetInterface(INTERFACE_NAME); AllJoyn.QStatus status = AddInterface(exampleIntf); if(!status) { chatText = "Chat Failed to add interface " + status.ToString() + "\n" + chatText; Debug.Log("Chat Failed to add interface " + status.ToString()); } chatMember = exampleIntf.GetMember("chat"); }
protected override void ListenerRegistered(AllJoyn.BusAttachment busAttachment) { chatText = "Chat ListenerRegistered: busAttachment=" + busAttachment + "\n" + chatText; Debug.Log("Chat ListenerRegistered: busAttachment=" + busAttachment); }
protected override bool AcceptSessionJoiner(ushort sessionPort, string joiner, AllJoyn.SessionOpts opts) { _sessionTest.acceptSessionJoinerFlag = true; return true; }
protected override bool AcceptSessionJoiner(ushort sessionPort, string joiner, AllJoyn.SessionOpts opts) { if (sessionPort != SERVICE_PORT) { chatText = "Chat Rejecting join attempt on unexpected session port " + sessionPort + "\n" + chatText; Debug.Log("Chat Rejecting join attempt on unexpected session port " + sessionPort); return false; } chatText = "Chat Accepting join session request from " + joiner + " (opts.proximity=" + opts.Proximity + ", opts.traffic=" + opts.Traffic + ", opts.transports=" + opts.Transports + ")\n" + chatText; Debug.Log("Chat Accepting join session request from " + joiner + " (opts.proximity=" + opts.Proximity + ", opts.traffic=" + opts.Traffic + ", opts.transports=" + opts.Transports + ")"); return true; }
protected override bool AcceptSessionJoiner(ushort sessionPort, string joiner, AllJoyn.SessionOpts opts) { if (sessionPort != SERVICE_PORT) { Console.WriteLine("Server Rejecting join attempt on unexpected session port {0}", sessionPort); return false; } Console.WriteLine("Server Accepting join session request from {0} (opts.proximity={1}, opts.traffic={2}, opts.transports={3})", joiner, opts.Proximity, opts.Traffic, opts.Transports); return true; }
public void ChatSignalHandler(AllJoyn.InterfaceDescription.Member member, string srcPath, AllJoyn.Message message) { Debug.Log("Client Chat msg - : "+message[0]); chatText = "Client Chat msg: ("+message[0]+ ")\n" + chatText; }
public TestBusObject(AllJoyn.BusAttachment bus, string path) : base(path, false) { AllJoyn.InterfaceDescription exampleIntf = bus.GetInterface(INTERFACE_NAME); AllJoyn.QStatus status = AddInterface(exampleIntf); if(!status) { Console.WriteLine("Server Failed to add interface {0}", status); } AllJoyn.InterfaceDescription.Member catMember = exampleIntf.GetMember("cat"); status = AddMethodHandler(catMember, this.Cat); if(!status) { Console.WriteLine("Server Failed to add method handler {0}", status); } }
protected override void ListenerRegistered(AllJoyn.BusAttachment busAttachment) { _busListenerTest.listenerRegistered = true; Notify(); }
protected void Cat(AllJoyn.InterfaceDescription.Member member, AllJoyn.Message message) { string outStr = (string)message[0] + (string)message[1]; AllJoyn.MsgArg outArgs = new AllJoyn.MsgArg(); outArgs = outStr; AllJoyn.QStatus status = MethodReply(message, outArgs); if(!status) { Console.WriteLine("Server Ping: Error sending reply"); } }
public void Ping(AllJoyn.InterfaceDescription.Member member, AllJoyn.Message message) { Assert.Equal(OBJECT_PATH, message.ObjectPath); Assert.Equal(INTERFACE_NAME, message.Interface); Assert.Equal("ping", message.MemberName); string outStr = (string)message[0]; AllJoyn.MsgArg outArgs = new AllJoyn.MsgArg(); outArgs = outStr; AllJoyn.QStatus status = MethodReply(message, outArgs); Assert.Equal(AllJoyn.QStatus.OK, status); }
public void Ping(AllJoyn.InterfaceDescription.Member member, AllJoyn.Message message) { string outStr = (string)message[0]; AllJoyn.MsgArg outArgs = new AllJoyn.MsgArg(); outArgs = outStr; AllJoyn.QStatus status = MethodReply(message, outArgs); Assert.Equal(AllJoyn.QStatus.OK, status); }