コード例 #1
0
        public void IsSecure_DepricatedCreateInterface()
        {
            AllJoyn.QStatus status = AllJoyn.QStatus.FAIL;

            AllJoyn.BusAttachment bus = null;
            bus = new AllJoyn.BusAttachment("InterfaceDescriptionTest", true);
            Assert.NotNull(bus);

            // create an insecure interface
            AllJoyn.InterfaceDescription testIntf = null;
            status = bus.CreateInterface(INTERFACE_NAME, false, out testIntf);
            Assert.Equal(AllJoyn.QStatus.OK, status);
            Assert.NotNull(testIntf);

            Assert.Equal(false, testIntf.IsSecure);

            bus.DeleteInterface(testIntf);

            // create a secure interface
            status = bus.CreateInterface(INTERFACE_NAME, true, out testIntf);
            Assert.Equal(AllJoyn.QStatus.OK, status);
            Assert.NotNull(testIntf);

            Assert.Equal(true, testIntf.IsSecure);

            bus.Dispose();
        }
コード例 #2
0
        public void TestNameOwnerChanged()
        {
            // 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;
            nameOwnerChanged   = false;

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

            // test name owner changed
            status = bus.RequestName(ObjectName, 0);
            Assert.Equal(AllJoyn.QStatus.OK, status);
            Wait(MaxWaitTime);
            Assert.Equal(true, nameOwnerChanged);

            busListener.Dispose();
            bus.Dispose();
        }
コード例 #3
0
        public void EnableConcurrentCallbacks_Used()
        {
            AllJoyn.QStatus status = AllJoyn.QStatus.FAIL;
            callbackStatus         = AllJoyn.QStatus.FAIL;
            listenerRegisteredFlag = false;
            nameOwnerChangedFlag   = false;

            mbus = new AllJoyn.BusAttachment("BusListenerTest", true);
            AllJoyn.BusListener busListener = new BusListenerEnableConcurrentCallbacks(this);

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

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

            mbus.RegisterBusListener(busListener);
            Wait(MaxWaitTime);
            Assert.True(listenerRegisteredFlag);

            mbus.RequestName(ObjectName, 0);
            Wait(MaxWaitTime);
            Assert.True(nameOwnerChangedFlag);
            Assert.Equal(AllJoyn.QStatus.OK, callbackStatus);

            mbus.UnregisterBusListener(busListener);
            mbus.Stop();
            mbus.Join();
            mbus.Dispose();
        }
コード例 #4
0
        public void PropertyAnnotations()
        {
            AllJoyn.QStatus status = AllJoyn.QStatus.FAIL;

            AllJoyn.BusAttachment bus = null;
            bus = new AllJoyn.BusAttachment("InterfaceDescriptionTest", true);
            Assert.NotNull(bus);

            // create the interface
            AllJoyn.InterfaceDescription testIntf = null;
            status = bus.CreateInterface(INTERFACE_NAME, out testIntf);
            Assert.Equal(AllJoyn.QStatus.OK, status);
            Assert.NotNull(testIntf);

            status = testIntf.AddProperty("prop", "s", AllJoyn.InterfaceDescription.AccessFlags.Read);
            Assert.Equal(AllJoyn.QStatus.OK, status);

            status = testIntf.AddPropertyAnnotation("prop", "org.alljoyn.test.annotation.one", "here");
            Assert.Equal(AllJoyn.QStatus.OK, status);
            status = testIntf.AddPropertyAnnotation("prop", "org.alljoyn.test.annotation.two", "lies");
            Assert.Equal(AllJoyn.QStatus.OK, status);
            status = testIntf.AddPropertyAnnotation("prop", "org.alljoyn.test.annotation.three", "some");
            Assert.Equal(AllJoyn.QStatus.OK, status);
            status = testIntf.AddPropertyAnnotation("prop", "org.alljoyn.test.annotation.four", "amazing");
            Assert.Equal(AllJoyn.QStatus.OK, status);
            status = testIntf.AddPropertyAnnotation("prop", "org.alljoyn.test.annotation.five", "treasure");
            Assert.Equal(AllJoyn.QStatus.OK, status);

            // activate the interface
            testIntf.Activate();

            AllJoyn.InterfaceDescription.Property property = testIntf.GetProperty("prop");
            Assert.Equal("prop", property.Name);
            Assert.Equal("s", property.Signature);
            Assert.Equal(AllJoyn.InterfaceDescription.AccessFlags.Read, property.Access);

            string value = "";

            Assert.True(testIntf.GetPropertyAnnotation("prop", "org.alljoyn.test.annotation.one", ref value));
            Assert.Equal("here", value);

            Assert.True(property.GetAnnotation("org.alljoyn.test.annotation.two", ref value));
            Assert.Equal("lies", value);

            Dictionary <string, string> annotations = property.GetAnnotations();

            Assert.Equal(5, annotations.Count);

            Assert.True(annotations.TryGetValue("org.alljoyn.test.annotation.one", out value));
            Assert.Equal("here", value);
            Assert.True(annotations.TryGetValue("org.alljoyn.test.annotation.two", out value));
            Assert.Equal("lies", value);
            Assert.True(annotations.TryGetValue("org.alljoyn.test.annotation.three", out value));
            Assert.Equal("some", value);
            Assert.True(annotations.TryGetValue("org.alljoyn.test.annotation.four", out value));
            Assert.Equal("amazing", value);
            Assert.True(annotations.TryGetValue("org.alljoyn.test.annotation.five", out value));
            Assert.Equal("treasure", value);
            bus.Dispose();
        }
コード例 #5
0
        public void IntrospectRemoteObject()
        {
            AllJoyn.BusAttachment busAttachment = new AllJoyn.BusAttachment("ProxyBusObjectTest", false);
            Assert.Equal(AllJoyn.QStatus.OK, busAttachment.Start());
            Assert.Equal(AllJoyn.QStatus.OK, busAttachment.Connect(AllJoynTestCommon.GetConnectSpec()));

            AllJoyn.ProxyBusObject proxyBusObject = new AllJoyn.ProxyBusObject(busAttachment, "org.alljoyn.Bus", "/org/alljoyn/Bus", 0);
            Assert.NotNull(proxyBusObject);

            Assert.Equal(AllJoyn.QStatus.OK, proxyBusObject.IntrospectRemoteObject());

            AllJoyn.InterfaceDescription interfaceDescription = proxyBusObject.GetInterface("org.freedesktop.DBus.Introspectable");

            string expectedIntrospect = "<interface name=\"org.freedesktop.DBus.Introspectable\">\n" +
                                        "  <method name=\"Introspect\">\n" +
                                        "    <arg name=\"data\" type=\"s\" direction=\"out\"/>\n" +
                                        "  </method>\n" +
                                        "</interface>\n";

            Assert.Equal(expectedIntrospect, interfaceDescription.Introspect());


            proxyBusObject.Dispose();
            Assert.Equal(AllJoyn.QStatus.OK, busAttachment.Stop());
            Assert.Equal(AllJoyn.QStatus.OK, busAttachment.Join());
            busAttachment.Dispose();
        }
コード例 #6
0
        public void DBusProxyObj()
        {
            AllJoyn.BusAttachment busAttachment = new AllJoyn.BusAttachment("BusAttachmentTest", true);

            Assert.Equal(AllJoyn.QStatus.OK, busAttachment.Start());
            Assert.Equal(AllJoyn.QStatus.OK, busAttachment.Connect());

            AllJoyn.ProxyBusObject dbusBusObj = busAttachment.DBusProxyObj;

            String wellKnownName = "org.alljoyn.test.BusAttachment";

            AllJoyn.MsgArg msgArg = new AllJoyn.MsgArg(2);
            msgArg[0] = wellKnownName;
            msgArg[1] = (uint)(AllJoyn.DBus.NameFlags.AllowReplacement | AllJoyn.DBus.NameFlags.DoNotQueue | AllJoyn.DBus.NameFlags.ReplaceExisting);

            AllJoyn.Message replyMsg = new AllJoyn.Message(busAttachment);

            Assert.Equal(AllJoyn.QStatus.OK, dbusBusObj.MethodCall("org.freedesktop.DBus", "RequestName", msgArg, replyMsg, 5000, 0));
            // TODO this keeps returning 4 which is DBUS_REQUEST_NAME_REPLY_EXISTS when it should return 1 DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER
            // unknown if this is an error only in Unity or in core code.  I suspect this issue is also in alljoyn_core code.

            AllJoyn.MsgArg nho_msgArg = new AllJoyn.MsgArg();
            nho_msgArg = wellKnownName;
            Assert.Equal(AllJoyn.QStatus.OK, dbusBusObj.MethodCall("org.freedesktop.DBus", "NameHasOwner", nho_msgArg, replyMsg, 5000, 0));
            Assert.True((bool)replyMsg[0]);

            Assert.Equal(AllJoyn.QStatus.OK, dbusBusObj.MethodCall("org.freedesktop.DBus", "ListNames", AllJoyn.MsgArg.Zero, replyMsg, 5000, 0));
            string[] sa = (string[])replyMsg[0];
            //the wellknown Name should be found in the list of strings returned.
            Assert.True(Array.IndexOf(sa, wellKnownName) > -1);
        }
コード例 #7
0
ファイル: ProxyBusObjectTest.cs プロジェクト: sindab/alljoyn
        public ProxyBusObjectTest()
        {
            busAttachment = new AllJoyn.BusAttachment("ProxyBusObjectTest", false);

            Assert.Equal(AllJoyn.QStatus.OK, busAttachment.Start());
            Assert.Equal(AllJoyn.QStatus.OK, busAttachment.Connect(AllJoynTestCommon.GetConnectSpec()));
        }
コード例 #8
0
        public void HasMember()
        {
            AllJoyn.QStatus status = AllJoyn.QStatus.FAIL;

            AllJoyn.BusAttachment bus = null;
            bus = new AllJoyn.BusAttachment("InterfaceDescriptionTest", true);
            Assert.NotNull(bus);

            // create the interface
            AllJoyn.InterfaceDescription testIntf = null;
            status = bus.CreateInterface(INTERFACE_NAME, out testIntf);
            Assert.Equal(AllJoyn.QStatus.OK, status);
            Assert.NotNull(testIntf);

            // Test adding a MethodCall
            status = testIntf.AddMember(AllJoyn.Message.Type.MethodCall, "ping", "s", "s", "in,out", AllJoyn.InterfaceDescription.AnnotationFlags.Default);
            Assert.Equal(AllJoyn.QStatus.OK, status);

            // Test adding a Signal
            status = testIntf.AddMember(AllJoyn.Message.Type.Signal, "chirp", "", "s", "chirp", AllJoyn.InterfaceDescription.AnnotationFlags.Default);
            Assert.Equal(AllJoyn.QStatus.OK, status);

            Assert.Equal(true, testIntf.HasMember("ping", "s", "s"));
            Assert.Equal(true, testIntf.HasMember("chirp", "", "s"));

            /*
             * expected to be false even though the members exist the signatures do not
             * match what is expected.
             */
            Assert.Equal(false, testIntf.HasMember("ping", "i", "s"));
            Assert.Equal(false, testIntf.HasMember("chirp", "b", null));
            Assert.Equal(false, testIntf.HasMember("invalid", "s", null));

            bus.Dispose();
        }
コード例 #9
0
        public void Activate()
        {
            AllJoyn.QStatus status = AllJoyn.QStatus.FAIL;

            AllJoyn.BusAttachment bus = null;
            bus = new AllJoyn.BusAttachment("InterfaceDescriptionTest", true);
            Assert.NotNull(bus);

            // create the interface
            AllJoyn.InterfaceDescription testIntf = null;
            status = bus.CreateInterface(INTERFACE_NAME, out testIntf);
            Assert.Equal(AllJoyn.QStatus.OK, status);
            Assert.NotNull(testIntf);

            // Test adding a MethodCall
            status = testIntf.AddMember(AllJoyn.Message.Type.MethodCall, "ping", "s", "s", "in,out", AllJoyn.InterfaceDescription.AnnotationFlags.Default);
            Assert.Equal(AllJoyn.QStatus.OK, status);

            // Test adding a Signal
            status = testIntf.AddMember(AllJoyn.Message.Type.Signal, "chirp", "", "s", "chirp", AllJoyn.InterfaceDescription.AnnotationFlags.Default);
            Assert.Equal(AllJoyn.QStatus.OK, status);

            // activate the interface
            testIntf.Activate();

            /* once the interface has been activated we should not be able to add new members */
            status = testIntf.AddMember(AllJoyn.Message.Type.MethodCall, "pong", "s", "s", "in,out", AllJoyn.InterfaceDescription.AnnotationFlags.Default);
            Assert.Equal(AllJoyn.QStatus.BUS_INTERFACE_ACTIVATED, status);

            bus.Dispose();
        }
コード例 #10
0
        public void TestObjectRegisteredUnregistered()
        {
            AllJoyn.QStatus status = AllJoyn.QStatus.FAIL;

            // create+start+connect bus attachment
            AllJoyn.BusAttachment bus = null;
            bus = new AllJoyn.BusAttachment("BusObjectTest", true);
            Assert.NotNull(bus);

            status = bus.Start();
            Assert.Equal(AllJoyn.QStatus.OK, status);

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

            // create the bus object
            TestBusObject testBusObject = new TestBusObject(bus, OBJECT_PATH, this);

            objectRegistered   = false;
            objectUnregistered = false;

            // test registering the bus object
            status = bus.RegisterBusObject(testBusObject);
            Assert.Equal(AllJoyn.QStatus.OK, status);
            Wait(MaxWaitTime);
            Assert.Equal(true, objectRegistered);

            // test unregistering the bus object
            bus.UnregisterBusObject(testBusObject);
            Wait(MaxWaitTime);
            Assert.Equal(true, objectUnregistered);

            bus.Dispose();
        }
コード例 #11
0
        public void HasProperty()
        {
            AllJoyn.QStatus status = AllJoyn.QStatus.FAIL;

            AllJoyn.BusAttachment bus = null;
            bus = new AllJoyn.BusAttachment("InterfaceDescriptionTest", true);
            Assert.NotNull(bus);

            // create the interface
            AllJoyn.InterfaceDescription testIntf = null;
            status = bus.CreateInterface(INTERFACE_NAME, out testIntf);
            Assert.Equal(AllJoyn.QStatus.OK, status);
            Assert.NotNull(testIntf);

            status = testIntf.AddProperty("prop1", "s", AllJoyn.InterfaceDescription.AccessFlags.Read);
            Assert.Equal(AllJoyn.QStatus.OK, status);
            status = testIntf.AddProperty("prop2", "i", AllJoyn.InterfaceDescription.AccessFlags.Write);
            Assert.Equal(AllJoyn.QStatus.OK, status);
            status = testIntf.AddProperty("prop3", "u", AllJoyn.InterfaceDescription.AccessFlags.ReadWrite);
            Assert.Equal(AllJoyn.QStatus.OK, status);

            // check for the properties
            Assert.Equal(true, testIntf.HasProperty("prop1"));
            Assert.Equal(true, testIntf.HasProperty("prop2"));
            Assert.Equal(true, testIntf.HasProperty("prop3"));
            Assert.Equal(false, testIntf.HasProperty("invalid_prop"));

            bus.Dispose();
        }
コード例 #12
0
        public void TestListenerRegisteredUnregistered()
        {
            AllJoyn.BusAttachment bus         = new AllJoyn.BusAttachment("BusListenerTest", true);
            AllJoyn.BusListener   busListener = new TestBusListener(this);
            listenerRegistered   = false;
            listenerUnregistered = false;
            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);

            bus.RegisterBusListener(busListener);
            Wait(MaxWaitTime);
            Assert.Equal(true, listenerRegistered);

            bus.UnregisterBusListener(busListener);
            Wait(MaxWaitTime);
            Assert.Equal(true, listenerUnregistered);

            // TODO: move these into a teardown method?
            busListener.Dispose();
            bus.Dispose();
        }
コード例 #13
0
        public void AddSignal()
        {
            AllJoyn.QStatus status = AllJoyn.QStatus.FAIL;

            AllJoyn.BusAttachment bus = null;
            bus = new AllJoyn.BusAttachment("InterfaceDescriptionTest", true);
            Assert.NotNull(bus);

            // create the interface
            AllJoyn.InterfaceDescription testIntf = null;
            status = bus.CreateInterface(INTERFACE_NAME, out testIntf);
            Assert.Equal(AllJoyn.QStatus.OK, status);
            Assert.NotNull(testIntf);

            status = testIntf.AddSignal("signal1", "s", "data", AllJoyn.InterfaceDescription.AnnotationFlags.Default);
            Assert.Equal(AllJoyn.QStatus.OK, status);

            // Verify the signal
            AllJoyn.InterfaceDescription.Member signalMember = null;
            signalMember = testIntf.GetMember("signal1");
            Assert.NotNull(signalMember);

            Assert.Equal(testIntf, signalMember.Iface);
            Assert.Equal(AllJoyn.Message.Type.Signal, signalMember.MemberType);
            Assert.Equal("signal1", signalMember.Name);
            Assert.Equal("s", signalMember.Signature);
            Assert.Equal("", signalMember.ReturnSignature);
            Assert.Equal("data", signalMember.ArgNames);
            //TODO add in code to use new annotation methods

            bus.Dispose();
        }
コード例 #14
0
ファイル: AjNet.cs プロジェクト: lickey10/u_ClientServer
        public TestBusObject(AllJoyn.BusAttachment bus, string path) : base(path, false)
        {
            AllJoyn.InterfaceDescription exampleIntf = bus.GetInterface(INTERFACE_NAME);
            AllJoyn.QStatus status = AddInterface(exampleIntf);
            if (!status)
            {
                serverText += "Server Failed to add interface " + status.ToString() + "\n";
                Debug.Log("Server Failed to add interface " + status.ToString());
            }

            AllJoyn.InterfaceDescription.Member catMember = exampleIntf.GetMember("acc");
            status = AddMethodHandler(catMember, this.Acc);
            if (!status)
            {
                serverText += "Server Failed to add method handler " + status.ToString() + "\n";
                Debug.Log("Server Failed to add method handler " + status.ToString());
            }

            catMember = exampleIntf.GetMember("data");
            status    = AddMethodHandler(catMember, this.Data);
            if (!status)
            {
                serverText += "Server Failed to add method handler " + status.ToString() + "\n";
                Debug.Log("Server Failed to add method handler " + status.ToString());
            }
        }
コード例 #15
0
        public void CreateDispose()
        {
            AllJoyn.BusAttachment busAttachment = new AllJoyn.BusAttachment("MessageTest", false);
            AllJoyn.Message       message       = new AllJoyn.Message(busAttachment);

            message.Dispose();
            busAttachment.Dispose();
        }
コード例 #16
0
        public void SignalAnnotations()
        {
            AllJoyn.QStatus status = AllJoyn.QStatus.FAIL;

            AllJoyn.BusAttachment bus = null;
            bus = new AllJoyn.BusAttachment("InterfaceDescriptionTest", true);
            Assert.NotNull(bus);

            // create the interface
            AllJoyn.InterfaceDescription testIntf = null;
            status = bus.CreateInterface(INTERFACE_NAME, out testIntf);
            Assert.Equal(AllJoyn.QStatus.OK, status);
            Assert.NotNull(testIntf);
            // Test adding a Signal
            status = testIntf.AddMember(AllJoyn.Message.Type.Signal, "chirp", "", "s", "chirp", AllJoyn.InterfaceDescription.AnnotationFlags.Default);
            Assert.Equal(AllJoyn.QStatus.OK, status);

            status = testIntf.AddMemberAnnotation("chirp", "org.alljoyn.test.annotation.one", "here");
            Assert.Equal(AllJoyn.QStatus.OK, status);
            status = testIntf.AddMemberAnnotation("chirp", "org.alljoyn.test.annotation.two", "lies");
            Assert.Equal(AllJoyn.QStatus.OK, status);
            status = testIntf.AddMemberAnnotation("chirp", "org.alljoyn.test.annotation.three", "some");
            Assert.Equal(AllJoyn.QStatus.OK, status);
            status = testIntf.AddMemberAnnotation("chirp", "org.alljoyn.test.annotation.four", "amazing");
            Assert.Equal(AllJoyn.QStatus.OK, status);
            status = testIntf.AddMemberAnnotation("chirp", "org.alljoyn.test.annotation.five", "treasure");
            Assert.Equal(AllJoyn.QStatus.OK, status);

            // activate the interface
            testIntf.Activate();

            string value = "";

            testIntf.GetMemberAnnotation("chirp", "org.alljoyn.test.annotation.one", ref value);
            Assert.Equal("here", value);

            AllJoyn.InterfaceDescription.Member signal = testIntf.GetMember("chirp");

            Assert.True(signal.GetAnnotation("org.alljoyn.test.annotation.two", ref value));
            Assert.Equal("lies", value);

            Dictionary <string, string> annotations = signal.GetAnnotations();

            Assert.Equal(5, annotations.Count);

            Assert.True(annotations.TryGetValue("org.alljoyn.test.annotation.one", out value));
            Assert.Equal("here", value);
            Assert.True(annotations.TryGetValue("org.alljoyn.test.annotation.two", out value));
            Assert.Equal("lies", value);
            Assert.True(annotations.TryGetValue("org.alljoyn.test.annotation.three", out value));
            Assert.Equal("some", value);
            Assert.True(annotations.TryGetValue("org.alljoyn.test.annotation.four", out value));
            Assert.Equal("amazing", value);
            Assert.True(annotations.TryGetValue("org.alljoyn.test.annotation.five", out value));
            Assert.Equal("treasure", value);

            bus.Dispose();
        }
コード例 #17
0
ファイル: BusAttachmentTest.cs プロジェクト: sindab/alljoyn
        public void Concurrency()
        {
            // The default value for concurrency is 4
            Assert.Equal <uint>(4, busAttachment.Concurrency);
            busAttachment.Dispose();

            busAttachment = new AllJoyn.BusAttachment("BusAttachmentTest", true, 8);
            Assert.Equal <uint>(8, busAttachment.Concurrency);
        }
コード例 #18
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");
            }
コード例 #19
0
        public BasicClient()
        {
            // Create message bus
            sMsgBus = new AllJoyn.BusAttachment("myApp", true);

            // Add org.alljoyn.Bus.method_sample interface
            AllJoyn.InterfaceDescription testIntf;
            AllJoyn.QStatus status = sMsgBus.CreateInterface(INTERFACE_NAME, false, out testIntf);
            if (status)
            {
                Console.WriteLine("Client Interface Created.");
                testIntf.AddMember(AllJoyn.Message.Type.MethodCall, "cat", "ss", "s", "inStr1,inStr2,outStr");
                testIntf.Activate();
            }
            else
            {
                Console.WriteLine("Client Failed to create interface 'org.alljoyn.Bus.method_sample'");
            }

            // Start the msg bus
            if (status)
            {
                status = sMsgBus.Start();
                if (status)
                {
                    Console.WriteLine("Client BusAttachment started.");
                }
                else
                {
                    Console.WriteLine("Client BusAttachment.Start failed.");
                }
            }

            // Connect to the bus
            if (status)
            {
                status = sMsgBus.Connect(connectArgs);
                if (status)
                {
                    Console.WriteLine("Client BusAttchement connected to " + connectArgs);
                }
                else
                {
                    Console.WriteLine("Client BusAttachment::Connect(" + connectArgs + ") failed.");
                }
            }

            // Create a bus listener
            sBusListener = new MyBusListener();

            if (status)
            {
                sMsgBus.RegisterBusListener(sBusListener);
                Console.WriteLine("Client BusListener Registered.");
            }
        }
コード例 #20
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();
        }
コード例 #21
0
        public void ServiceName()
        {
            AllJoyn.BusAttachment busAttachment = new AllJoyn.BusAttachment("ProxyBusObjectTest", false);
            Assert.Equal(AllJoyn.QStatus.OK, busAttachment.Start());
            Assert.Equal(AllJoyn.QStatus.OK, busAttachment.Connect(AllJoynTestCommon.GetConnectSpec()));

            AllJoyn.ProxyBusObject proxyBusObject = new AllJoyn.ProxyBusObject(busAttachment, "org.alljoyn.Bus", "/org/alljoyn/Bus", 0);
            Assert.NotNull(proxyBusObject);

            Assert.Equal("org.alljoyn.Bus", proxyBusObject.ServiceName);
        }
コード例 #22
0
ファイル: AjNet.cs プロジェクト: lickey10/u_ClientServer
 public void Disconnect()
 {
     if (msgBus != null)
     {
         if (sJoinComplete)
         {
             msgBus.LeaveSession(theSessionId);
         }
         msgBus = null;
     }
     sJoinComplete = false;
 }
コード例 #23
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");
            }
コード例 #24
0
        public ConcurrentCallbackTest()
        {
            mbus = new AllJoyn.BusAttachment("BusListenerTest", true);

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

            // connect to the bus
            status = mbus.Connect(AllJoynTestCommon.GetConnectSpec());
            Assert.Equal(AllJoyn.QStatus.OK, status);
        }
コード例 #25
0
        public ObjectSecurityTest()
        {
            serviceBus = new AllJoyn.BusAttachment("AuthListenerTestService", false);

            Assert.Equal(AllJoyn.QStatus.OK, serviceBus.Start());
            Assert.Equal(AllJoyn.QStatus.OK, serviceBus.Connect(AllJoynTestCommon.GetConnectSpec()));

            clientBus = new AllJoyn.BusAttachment("AuthListenerTestClient", false);

            Assert.Equal(AllJoyn.QStatus.OK, clientBus.Start());
            Assert.Equal(AllJoyn.QStatus.OK, clientBus.Connect(AllJoynTestCommon.GetConnectSpec()));
        }
コード例 #26
0
        public SignalsTest()
        {
            // create+start+connect bus attachment
            bus = new AllJoyn.BusAttachment("SignalsTest", true);
            Assert.NotNull(bus);

            status = bus.Start();
            Assert.Equal(AllJoyn.QStatus.OK, status);

            status = bus.Connect(AllJoynTestCommon.GetConnectSpec());
            Assert.Equal(AllJoyn.QStatus.OK, status);
        }
コード例 #27
0
        public void GetMember()
        {
            AllJoyn.QStatus status = AllJoyn.QStatus.FAIL;

            AllJoyn.BusAttachment bus = null;
            bus = new AllJoyn.BusAttachment("InterfaceDescriptionTest", true);
            Assert.NotNull(bus);

            // create the interface
            AllJoyn.InterfaceDescription testIntf = null;
            status = bus.CreateInterface(INTERFACE_NAME, out testIntf);
            Assert.Equal(AllJoyn.QStatus.OK, status);
            Assert.NotNull(testIntf);

            // Test adding a MethodCall
            status = testIntf.AddMember(AllJoyn.Message.Type.MethodCall, "ping", "s", "s", "in,out", AllJoyn.InterfaceDescription.AnnotationFlags.Default);
            Assert.Equal(AllJoyn.QStatus.OK, status);

            // Test adding a Signal
            status = testIntf.AddMember(AllJoyn.Message.Type.Signal, "chirp", "", "s", "chirp", AllJoyn.InterfaceDescription.AnnotationFlags.Default);
            Assert.Equal(AllJoyn.QStatus.OK, status);

            // Verify the ping member
            AllJoyn.InterfaceDescription.Member pingMember = null;
            pingMember = testIntf.GetMember("ping");
            Assert.NotNull(pingMember);

            Assert.Equal(testIntf, pingMember.Iface);
            Assert.Equal(AllJoyn.Message.Type.MethodCall, pingMember.MemberType);
            Assert.Equal("ping", pingMember.Name);
            Assert.Equal("s", pingMember.Signature);
            Assert.Equal("s", pingMember.ReturnSignature);
            Assert.Equal("in,out", pingMember.ArgNames);
            //TODO add in code to use new annotation methods
            //Assert.Equal(AllJoyn.InterfaceDescription.AnnotationFlags.Default, pingMember.Annotation);

            // Verify the chirp member
            AllJoyn.InterfaceDescription.Member chirpMember = null;
            chirpMember = testIntf.GetMember("chirp");
            Assert.NotNull(chirpMember);

            Assert.Equal(testIntf, chirpMember.Iface);
            Assert.Equal(AllJoyn.Message.Type.Signal, chirpMember.MemberType);
            Assert.Equal("chirp", chirpMember.Name);
            Assert.Equal("", chirpMember.Signature);
            Assert.Equal("s", chirpMember.ReturnSignature);
            Assert.Equal("chirp", chirpMember.ArgNames);
            //TODO add in code to use new annotation methods
            //Assert.Equal(AllJoyn.InterfaceDescription.AnnotationFlags.Default, chirpMember.Annotation);

            bus.Dispose();
        }
コード例 #28
0
ファイル: BusAttachmentTest.cs プロジェクト: sindab/alljoyn
        // Setup
        public BusAttachmentTest()
        {
            notifyEventOne = new AutoResetEvent(false);
            notifyEventTwo = new AutoResetEvent(false);

            handledSignalsOne = false;
            handledSignalsTwo = false;
            signalOneMsg      = "";
            signalTwoMsg      = "";

            busAttachment = new AllJoyn.BusAttachment("BusAttachmentTest", true);
            Assert.NotNull(busAttachment);
        }
コード例 #29
0
            public MethodTestBusObject(AllJoyn.BusAttachment bus, string path)
                : base(path, false)
            {
                // add the interface to the bus object
                AllJoyn.InterfaceDescription testIntf = bus.GetInterface(INTERFACE_NAME);
                AllJoyn.QStatus status = AddInterface(testIntf);
                Assert.Equal(AllJoyn.QStatus.OK, status);

                // register a method handler for the ping method
                AllJoyn.InterfaceDescription.Member pingMember = testIntf.GetMember("ping");
                status = AddMethodHandler(pingMember, this.Ping);
                Assert.Equal(AllJoyn.QStatus.OK, status);
            }
コード例 #30
0
        public void CreateDispose()
        {
            AllJoyn.BusAttachment busAttachment = new AllJoyn.BusAttachment("ProxyBusObjectTest", false);
            Assert.Equal(AllJoyn.QStatus.OK, busAttachment.Start());
            Assert.Equal(AllJoyn.QStatus.OK, busAttachment.Connect(AllJoynTestCommon.GetConnectSpec()));

            AllJoyn.ProxyBusObject proxyBusObject = new AllJoyn.ProxyBusObject(busAttachment, "org.alljoyn.Bus", "/org/alljoyn/Bus", 0);
            Assert.NotNull(proxyBusObject);
            proxyBusObject.Dispose();
            Assert.Equal(AllJoyn.QStatus.OK, busAttachment.Stop());
            Assert.Equal(AllJoyn.QStatus.OK, busAttachment.Join());
            busAttachment.Dispose();
        }