예제 #1
0
        public void GetMethod()
        {
            // 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
            Assert.Equal(AllJoyn.QStatus.OK, testIntf.AddMethod("ping", "s", "s", "in,out"));
            Assert.Equal(AllJoyn.QStatus.OK, testIntf.AddSignal("foo", "", ""));

            // Verify the ping member
            AllJoyn.InterfaceDescription.Member pingMember = null;
            pingMember = testIntf.GetMethod("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);

            AllJoyn.InterfaceDescription.Member fooMember = null;
            fooMember = testIntf.GetMethod("foo");
            // since "foo" is a signal is should return null when using GetMethod
            Assert.Null(fooMember);

            fooMember = testIntf.GetMethod("bar");
            // since "bar" is not a member of the interface it should be null
            Assert.Null(fooMember);
        }
예제 #2
0
        public void RegisterUnregisterSessionlessSignals()
        {
            AllJoyn.InterfaceDescription testIntf;
            Assert.Equal(AllJoyn.QStatus.OK, bus.CreateInterface("org.alljoyn.test.signalstest", out testIntf));
            Assert.Equal(AllJoyn.QStatus.OK, testIntf.AddSignal("testSignal", "s", "newName"));
            testIntf.Activate();

            TestBusObject testObj = new TestBusObject("/org/alljoyn/test/signal");

            Assert.Equal(AllJoyn.QStatus.OK, testObj.AddInterface(testIntf));
            Assert.Equal(AllJoyn.QStatus.OK, bus.RegisterBusObject(testObj));

            AllJoyn.InterfaceDescription.Member mySignalMember = testIntf.GetMember("testSignal");

            Assert.Equal(AllJoyn.QStatus.OK, bus.AddMatch("type='signal',sessionless='t',interface='org.alljoyn.test.signalstest,member='testSignal'"));

            AllJoyn.Message msg = new AllJoyn.Message(bus);
            AllJoyn.MsgArg  arg = new AllJoyn.MsgArg();

            Assert.Equal(AllJoyn.QStatus.OK, arg.Set("s", "AllJoyn"));
            Assert.Equal(AllJoyn.QStatus.OK, testObj.SendTestSignal("", 0, mySignalMember, arg, 0, AllJoyn.ALLJOYN_FLAG_SESSIONLESS, msg));

            Assert.Equal(AllJoyn.QStatus.OK, testObj.CancelSessionlessMessage(msg.CallSerial));

            Assert.Equal(AllJoyn.QStatus.OK, testObj.SendTestSignal("", 0, mySignalMember, arg, 0, AllJoyn.ALLJOYN_FLAG_SESSIONLESS, msg));
            Assert.Equal(AllJoyn.QStatus.OK, testObj.CancelSessionlessMessage(msg));
        }
예제 #3
0
 public void EnemyInitSignalHandler(AllJoyn.InterfaceDescription.Member member, string srcPath, AllJoyn.Message message)
 {
     if (playerNick != (string)message [0])
     {
         int index = enemyDB.FindIndex(
             delegate(EnemyData data)
         {
             return(data.name == (string)message[1]);
         });
         if (index == -1)
         {
             EnemyData temporaryData = new EnemyData();
             temporaryData.name      = (string)message [1];
             temporaryData.posX      = (double)message [2];
             temporaryData.posY      = (double)message [3];
             temporaryData.posZ      = (double)message [4];
             temporaryData.angleY    = (double)message [5];
             temporaryData.IsSpawned = false;
             enemyDB.Add(temporaryData);
         }
         else
         {
             enemyDB[index].posX    = (double)message [2];
             playerDB[index].posY   = (double)message [3];
             playerDB[index].posZ   = (double)message [4];
             playerDB[index].angleY = (double)message [5];
         }
     }
 }
예제 #4
0
        public void GetSignal()
        {
            // create the interface
            AllJoyn.InterfaceDescription testIntf = null;
            status = bus.CreateInterface(INTERFACE_NAME, out testIntf);
            Assert.Equal(AllJoyn.QStatus.OK, status);
            Assert.NotNull(testIntf);
            Assert.Equal(AllJoyn.QStatus.OK, testIntf.AddMethod("foo", "", "", ""));
            status = testIntf.AddSignal("chirp", "s", "data", AllJoyn.InterfaceDescription.AnnotationFlags.Default);
            Assert.Equal(AllJoyn.QStatus.OK, status);

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

            Assert.Equal(testIntf, signalMember.Iface);
            Assert.Equal(AllJoyn.Message.Type.Signal, signalMember.MemberType);
            Assert.Equal("chirp", signalMember.Name);
            Assert.Equal("s", signalMember.Signature);
            Assert.Equal("", signalMember.ReturnSignature);
            Assert.Equal("data", signalMember.ArgNames);

            AllJoyn.InterfaceDescription.Member methodMember = null;
            methodMember = testIntf.GetSignal("foo");
            //since "foo" is a method GetSignal should return null
            Assert.Null(methodMember);

            methodMember = testIntf.GetSignal("bar");
            // "bar" is not a member of the interface it should return null
            Assert.Null(methodMember);
        }
예제 #5
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)
            {
                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());
            }
        }
예제 #6
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();
        }
예제 #7
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));
 }
예제 #8
0
 public void TestSignalHandlerTwo(AllJoyn.InterfaceDescription.Member member, string srcPath, AllJoyn.Message message)
 {
     signalTwoMsg = message[0];
     // mark that the signal was received
     handledSignalsTwo = true;
     NotifyEventTwo();
 }
예제 #9
0
        public void MethodAnnotations()
        {
            // 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);
            status = testIntf.AddMemberAnnotation("ping", "one", "black_cat");
            Assert.Equal(AllJoyn.QStatus.OK, status);

            status = testIntf.AddMemberAnnotation("ping", "org.alljoyn.test.annotation.one", "here");
            Assert.Equal(AllJoyn.QStatus.OK, status);
            status = testIntf.AddMemberAnnotation("ping", "org.alljoyn.test.annotation.two", "lies");
            Assert.Equal(AllJoyn.QStatus.OK, status);
            status = testIntf.AddMemberAnnotation("ping", "org.alljoyn.test.annotation.three", "some");
            Assert.Equal(AllJoyn.QStatus.OK, status);
            status = testIntf.AddMemberAnnotation("ping", "org.alljoyn.test.annotation.four", "amazing");
            Assert.Equal(AllJoyn.QStatus.OK, status);
            status = testIntf.AddMemberAnnotation("ping", "org.alljoyn.test.annotation.five", "treasure");
            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();

            string value = "";

            testIntf.GetMemberAnnotation("ping", "one", ref value);
            Assert.Equal("black_cat", value);

            AllJoyn.InterfaceDescription.Member member = testIntf.GetMember("ping");

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

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

            Assert.Equal(6, 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);
            Assert.True(annotations.TryGetValue("one", out value));
            Assert.Equal("black_cat", value);
        }
예제 #10
0
            protected void Ding(AllJoyn.InterfaceDescription.Member member, AllJoyn.Message message)
            {
                AllJoyn.MsgArg outArgs = new AllJoyn.MsgArg();
                outArgs = "Hello from Ding.";

                AllJoyn.QStatus status = MethodReply(message, outArgs);
                Assert.Equal(AllJoyn.QStatus.OK, status);
            }
예제 #11
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();
        }
예제 #12
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");
            }
예제 #13
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);
            }
예제 #14
0
 public void EnemyHPSignalHandler(AllJoyn.InterfaceDescription.Member member, string srcPath, AllJoyn.Message message)
 {
     if (playerNick != (string)message [0])
     {
         int index = enemyDB.FindIndex(
             delegate(EnemyData data)
         {
             return(data.name == (string)message[1]);
         });
         enemyDB.RemoveAt(index);
     }
 }
예제 #15
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");
            }
예제 #16
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();
        }
예제 #17
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);
            }
예제 #18
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);
            }
예제 #19
0
            protected void Cat(AllJoyn.InterfaceDescription.Member member, AllJoyn.Message message)
            {
                string outStr = (string)message[0] + (string)message[1];

                AllJoyn.MsgArgs outArgs = new AllJoyn.MsgArgs(1);
                outArgs[0] = outStr;

                AllJoyn.QStatus status = MethodReply(message, outArgs);
                if (!status)
                {
                    Console.WriteLine("Server Ping: Error sending reply");
                }
            }
예제 #20
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)
                {
                    //Debug.LogError("Failed to add interface " + status.ToString());
                }

                playerMember    = exampleIntf.GetMember("player");
                enemyInitMember = exampleIntf.GetMember("enemyInit");
                enemyAgroMember = exampleIntf.GetMember("enemyAgro");
                enemyHPMember   = exampleIntf.GetMember("enemyHP");
            }
예제 #21
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)
                {
                    serverText += "Server Ping: Error sending reply\n";
                    Debug.Log("Server Ping: Error sending reply");
                }
            }
예제 #22
0
        public void PositionUpdateSignalHandler(AllJoyn.InterfaceDescription.Member member, string srcPath, AllJoyn.Message message)
        {
            double positionX = message[0];

            double positionY = message[1];

            double positionZ = message[2];

            Vector3 position = new Vector3((float)positionX, (float)positionY, (float)positionZ);

            Debug.Log("New Position: " + position.ToString());
            newCoordinates = position;

            neueKoordinaten = true;
        }
예제 #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)
                {
                    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);
                }
            }
예제 #24
0
            protected 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);

//Continue testing obsolete method calls till they are removed.
#pragma warning disable 618
                AllJoyn.MsgArgs outArgs2 = new AllJoyn.MsgArgs(1);
                outArgs2[0] = outStr;

                status = MethodReply(message, outArgs2);
                Assert.Equal(AllJoyn.QStatus.OK, status);
#pragma warning restore 618
            }
예제 #25
0
        public AllJoyn.QStatus SetUpAuthService()
        {
            AllJoyn.QStatus status = AllJoyn.QStatus.FAIL;

            TestBusListener busListener = new TestBusListener(this);

            serviceBus.RegisterBusListener(busListener);

            busObject = new TestBusObject(OBJECT_PATH);
            AllJoyn.InterfaceDescription ifaceDescritpion = serviceBus.GetInterface(INTERFACE_NAME);
            status = busObject.AddInterface(ifaceDescritpion);
            if (!status)
            {
                return(status);
            }

            AllJoyn.InterfaceDescription.Member ping_member = ifaceDescritpion.GetMethod("ping");

            status = busObject.AddMethodHandler(ping_member, busObject.Ping);
            if (!status)
            {
                return(status);
            }

            status = serviceBus.RegisterBusObject(busObject, true);
            if (!status)
            {
                return(status);
            }

            Assert.True(busObject.IsSecure);

            status = serviceBus.RequestName(WELLKNOWN_NAME,
                                            AllJoyn.DBus.NameFlags.ReplaceExisting |
                                            AllJoyn.DBus.NameFlags.DoNotQueue |
                                            AllJoyn.DBus.NameFlags.AllowReplacement);
            if (!status)
            {
                return(status);
            }
            Wait(TimeSpan.FromSeconds(5));
            return(status);
        }
예제 #26
0
        protected void Data(AllJoyn.InterfaceDescription.Member member, AllJoyn.Message message)
        {
//			string in1 = message[0];
//			serverText += string.Format ("Acc {0} {1}\n", message.Sender, in1);
//			Debug.Log (string.Format ("Acc {0} {1}", message.Sender, in1));
//
            if (ajNet.manager != null)
            {
                ajNet.manager.DataReceived(message.Sender, message[0], message[1]);
            }

            AllJoyn.MsgArg outArgs = new AllJoyn.MsgArg();
            outArgs = (string)"";

            AllJoyn.QStatus status = MethodReply(message, outArgs);
            if (!status)
            {
                serverText += "Server Ping: Error sending reply\n";
                Debug.Log("Server Ping: Error sending reply");
            }
        }
예제 #27
0
        public void RegisterUnregisterSessionlessSignals()
        {
            AllJoyn.QStatus status = AllJoyn.QStatus.FAIL;

            // create+start+connect bus attachment
            AllJoyn.BusAttachment bus = null;
            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);

            AllJoyn.InterfaceDescription testIntf;
            Assert.Equal(AllJoyn.QStatus.OK, bus.CreateInterface("org.alljoyn.test.signalstest", out testIntf));
            Assert.Equal(AllJoyn.QStatus.OK, testIntf.AddSignal("testSignal", "s", "newName"));
            testIntf.Activate();

            TestBusObject testObj = new TestBusObject("/org/alljoyn/test/signal");

            Assert.Equal(AllJoyn.QStatus.OK, testObj.AddInterface(testIntf));
            Assert.Equal(AllJoyn.QStatus.OK, bus.RegisterBusObject(testObj));

            AllJoyn.InterfaceDescription.Member mySignalMember = testIntf.GetMember("testSignal");

            Assert.Equal(AllJoyn.QStatus.OK, bus.AddMatch("type='signal',sessionless='t',interface='org.alljoyn.test.signalstest,member='testSignal'"));

            AllJoyn.Message msg = new AllJoyn.Message(bus);
            AllJoyn.MsgArg  arg = new AllJoyn.MsgArg();

            Assert.Equal(AllJoyn.QStatus.OK, arg.Set("s", "AllJoyn"));
            Assert.Equal(AllJoyn.QStatus.OK, testObj.SendTestSignal("", 0, mySignalMember, arg, 0, AllJoyn.ALLJOYN_FLAG_SESSIONLESS, msg));

            Assert.Equal(AllJoyn.QStatus.OK, testObj.CancelSessionlessMessage(msg.CallSerial));

            Assert.Equal(AllJoyn.QStatus.OK, testObj.SendTestSignal("", 0, mySignalMember, arg, 0, AllJoyn.ALLJOYN_FLAG_SESSIONLESS, msg));
            Assert.Equal(AllJoyn.QStatus.OK, testObj.CancelSessionlessMessage(msg));
        }
예제 #28
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;
 }
예제 #29
0
        public void CloseDown()
        {
            if (msgBus == null)
            {
                return;                 //no need to clean anything up
            }
            AllJoynStarted = false;
            LeaveSession();
            AllJoyn.QStatus status = msgBus.CancelFindAdvertisedName(SERVICE_NAME);
            if (!status)
            {
                chatText = "CancelAdvertisedName failed status(" + status.ToString() + ")\n" + chatText;
                Debug.Log("CancelAdvertisedName failed status(" + status.ToString() + ")");
            }
            status = msgBus.CancelAdvertisedName(myAdvertisedName, opts.Transports);
            if (!status)
            {
                chatText = "CancelAdvertisedName failed status(" + status.ToString() + ")\n" + chatText;
                Debug.Log("CancelAdvertisedName failed status(" + status.ToString() + ")");
            }
            status = msgBus.ReleaseName(myAdvertisedName);
            if (!status)
            {
                chatText = "ReleaseName failed status(" + status.ToString() + ")\n" + chatText;
                Debug.Log("ReleaseName status(" + status.ToString() + ")");
            }
            status = msgBus.UnbindSessionPort(SERVICE_PORT);
            if (!status)
            {
                chatText = "UnbindSessionPort failed status(" + status.ToString() + ")\n" + chatText;
                Debug.Log("UnbindSessionPort status(" + status.ToString() + ")");
            }

            status = msgBus.Disconnect(connectedVal);
            if (!status)
            {
                chatText = "Disconnect failed status(" + status.ToString() + ")\n" + chatText;
                Debug.Log("Disconnect status(" + status.ToString() + ")");
            }

            AllJoyn.InterfaceDescription.Member chatMember = testIntf.GetMember("chat");
            status     = msgBus.UnregisterSignalHandler(this.ChatSignalHandler, chatMember, null);
            chatMember = null;
            if (!status)
            {
                chatText = "UnregisterSignalHandler failed status(" + status.ToString() + ")\n" + chatText;
                Debug.Log("UnregisterSignalHandler status(" + status.ToString() + ")");
            }
            if (sessionListener != null)
            {
                status          = msgBus.SetSessionListener(null, currentSessionId);
                sessionListener = null;
                if (!status)
                {
                    chatText = "SetSessionListener failed status(" + status.ToString() + ")\n" + chatText;
                    Debug.Log("SetSessionListener status(" + status.ToString() + ")");
                }
            }
            chatText = "No Exceptions(" + status.ToString() + ")\n" + chatText;
            Debug.Log("No Exceptions(" + status.ToString() + ")");
            currentSessionId     = 0;
            currentJoinedSession = null;
            sFoundName.Clear();

            connectedVal        = null;
            msgBus              = null;
            busListener         = null;
            sessionPortListener = null;
            testObj             = null;
            testIntf            = null;
            opts             = null;
            myAdvertisedName = null;

            AllJoynStarted = false;

            AllJoyn.StopAllJoynProcessing();             //Stop processing alljoyn callbacks
        }
예제 #30
0
        public void UnregisterSignalHandler()
        {
            AllJoyn.QStatus status = AllJoyn.QStatus.FAIL;

            // create bus attachment
            AllJoyn.BusAttachment bus = null;
            bus = new AllJoyn.BusAttachment("BusAttachmentTest", true);
            Assert.NotNull(bus);

            // create the interface description
            AllJoyn.InterfaceDescription testIntf = null;
            status = bus.CreateInterface("org.alljoyn.test.BusAttachment", out testIntf);
            Assert.Equal(AllJoyn.QStatus.OK, status);
            Assert.NotNull(testIntf);

            // add the signal member to the interface
            status = testIntf.AddSignal("testSignal", "s", "msg", 0);
            Assert.Equal(AllJoyn.QStatus.OK, status);

            // activate the interface
            testIntf.Activate();

            // 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);

            // create the bus object &
            // add the interface to the bus object
            TestBusObject testBusObject = new TestBusObject(bus, "/test");

            bus.RegisterBusObject(testBusObject);

            // get the signal member from the interface description
            AllJoyn.InterfaceDescription.Member testSignalMember = testIntf.GetMember("testSignal");

            // register both signal handlers
            status = bus.RegisterSignalHandler(this.TestSignalHandlerOne, testSignalMember, null);
            Assert.Equal(AllJoyn.QStatus.OK, status);
            status = bus.RegisterSignalHandler(this.TestSignalHandlerTwo, testSignalMember, null);
            Assert.Equal(AllJoyn.QStatus.OK, status);

            // add match for the signal
            status = bus.AddMatch("type='signal',member='testSignal'");
            Assert.Equal(AllJoyn.QStatus.OK, status);

            handledSignalsOne = false;
            handledSignalsTwo = false;
            signalOneMsg      = null;
            signalTwoMsg      = null;

            // send a signal
            testBusObject.SendTestSignal("test msg");

            WaitEventOne(TimeSpan.FromSeconds(2));
            WaitEventTwo(TimeSpan.FromSeconds(2));

            // make sure that both handlers got the signal
            Assert.Equal(true, handledSignalsOne);
            Assert.Equal("test msg", signalOneMsg);
            Assert.Equal(true, handledSignalsTwo);
            Assert.Equal("test msg", signalTwoMsg);

            // now unregister one handler & make sure it doesn't receive the signal
            handledSignalsOne = false;
            handledSignalsTwo = false;
            signalOneMsg      = null;
            signalTwoMsg      = null;

            status = bus.UnregisterSignalHandler(this.TestSignalHandlerOne, testSignalMember, null);
            Assert.Equal(AllJoyn.QStatus.OK, status);

            // send another signal
            testBusObject.SendTestSignal("test msg");

            // wait to see if we receive the signal
            WaitEventTwo(TimeSpan.FromSeconds(2));

            // make sure that only the second handler got the signal
            Assert.Equal(false, handledSignalsOne);
            Assert.Null(signalOneMsg);
            Assert.Equal(true, handledSignalsTwo);
            Assert.Equal("test msg", signalTwoMsg);

            // TODO: move these into a teardown method?
            bus.Dispose();
        }