Esempio n. 1
0
            /**
             * 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;
            }
Esempio n. 2
0
 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;
 }
Esempio n. 3
0
            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);
            }
Esempio n. 4
0
            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);
            }
Esempio n. 5
0
            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);
            }
Esempio n. 6
0
 protected override void LostAdvertisedName(string name, AllJoyn.TransportMask transport, string namePrefix)
 {
     _busListenerTest.lostAdvertisedName = true;
     Notify();
 }
Esempio n. 7
0
 protected override void FoundAdvertisedName(string name, AllJoyn.TransportMask transport, string namePrefix)
 {
     _busListenerTest.transportFound |= transport;
     _busListenerTest.foundAdvertisedName = true;
     Notify();
 }
Esempio n. 8
0
			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();
				}
			}
Esempio n. 9
0
 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);
     }
 }
Esempio n. 10
0
			protected override bool VerifyCredentials(string authMechanism, string peerName, AllJoyn.Credentials credentials)
			{
				_authListenerTest.authflags.verifyCreds_client = true;
				return true;
			}
Esempio n. 11
0
			protected override void SecurityViolation(AllJoyn.QStatus status, AllJoyn.Message msg)
			{
				_authListenerTest.authflags.securityViolation_service = true;
			}
Esempio n. 12
0
			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;
			}
Esempio n. 13
0
 protected override bool VerifyCredentials(string authMechanism, string peerName, AllJoyn.Credentials credentials)
 {
     _objectSecurityTest.authflags.verifyCreds_service = true;
     return true;
 }
Esempio n. 14
0
            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;
            }
Esempio n. 15
0
 protected override void SecurityViolation(AllJoyn.QStatus status, AllJoyn.Message msg)
 {
     _objectSecurityTest.authflags.securityViolation_client = true;
 }
Esempio n. 16
0
			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");
			}
Esempio n. 17
0
            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;
            }
Esempio n. 18
0
			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();
 }
Esempio n. 20
0
			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;
			}
Esempio n. 21
0
            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);
            }
Esempio n. 22
0
			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;
			}
Esempio n. 23
0
 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);
 }
Esempio n. 24
0
			protected override void SecurityViolation(AllJoyn.QStatus status, AllJoyn.Message msg)
			{
				_authListenerTest.authflags.securityViolation_client = true;
				_authListenerTest.Notify();
			}
Esempio n. 25
0
            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");
            }
Esempio n. 26
0
 protected override void ListenerRegistered(AllJoyn.BusAttachment busAttachment)
 {
     chatText = "Chat ListenerRegistered: busAttachment=" + busAttachment + "\n" + chatText;
     Debug.Log("Chat ListenerRegistered: busAttachment=" + busAttachment);
 }
Esempio n. 27
0
			protected override bool AcceptSessionJoiner(ushort sessionPort, string joiner, AllJoyn.SessionOpts opts)
			{
				_sessionTest.acceptSessionJoinerFlag = true;
				return true;
			}
Esempio n. 28
0
 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;
 }
Esempio n. 29
0
 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;
 }
Esempio n. 30
0
 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;
 }
Esempio n. 31
0
            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);
                }
            }
Esempio n. 32
0
 protected override void ListenerRegistered(AllJoyn.BusAttachment busAttachment)
 {
     _busListenerTest.listenerRegistered = true;
     Notify();
 }
Esempio n. 33
0
            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");
                }
            }
Esempio n. 34
0
			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);
			}
Esempio n. 35
0
			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);
			}