コード例 #1
0
ファイル: MsgArgsTest.cs プロジェクト: hybridgroup/alljoyn
		public void BasicAssignment()
		{
			AllJoyn.MsgArgs arg = new AllJoyn.MsgArgs(1);
			arg[0] = (byte)42;
			Assert.Equal((byte)42, (byte)arg[0]);
			arg[0] = true;
			Assert.True((bool)arg[0]);

			arg[0] = false;
			Assert.False((bool)arg[0]);

			arg[0] = (short)42;
			Assert.Equal((short)42, (short)arg[0]);

			arg[0] = (ushort)0xBEBE;
			Assert.Equal((ushort)0xBEBE, (ushort)arg[0]);

			arg[0] = (int)-9999;
			Assert.Equal((int)-9999, (int)arg[0]);

			arg[0] = (uint)0x32323232;
			Assert.Equal((uint)0x32323232, (uint)arg[0]);

			arg[0] = (long)-1;
			Assert.Equal((long)-1, (long)arg[0]);

			arg[0] = (ulong)0x6464646464646464;
			Assert.Equal((ulong)0x6464646464646464, (ulong)arg[0]);

			arg[0] = (float)1.61803f;
			Assert.Equal((float)1.61803f, (float)arg[0]);

			arg[0] = (double)3.14159265D;
			Assert.Equal((double)3.14159265D, (double)arg[0]);

			arg[0] = (string)"this is a string";
			Assert.Equal("this is a string", (string)arg[0]);

			arg[0].ObjectPath = "/org/foo/bar";
			Assert.Equal("/org/foo/bar", arg[0].ObjectPath);

			//assignment of an array
			AllJoyn.MsgArgs arg3 = new AllJoyn.MsgArgs(3);
			arg3[0] = (byte)5;
			arg3[1] = (byte)13;
			arg3[2] = (byte)42;

			Assert.Equal((byte)5, (byte)arg3[0]);
			Assert.Equal((byte)13, (byte)arg3[1]);
			Assert.Equal((byte)42, (byte)arg3[2]);
		}
コード例 #2
0
ファイル: MsgArgsTest.cs プロジェクト: hybridgroup/alljoyn
		public void BasicSet()
		{
			AllJoyn.MsgArgs arg = new AllJoyn.MsgArgs(1);

			Assert.Equal(AllJoyn.QStatus.OK, arg[0].Set((byte)13));
			Assert.Equal((byte)13, (byte)arg[0]);

			Assert.Equal(AllJoyn.QStatus.OK, arg[0].Set(true));
			Assert.True((bool)arg[0]);

			Assert.Equal(AllJoyn.QStatus.OK, arg[0].Set((short)42));
			Assert.Equal((short)42, (short)arg[0]);

			Assert.Equal(AllJoyn.QStatus.OK, arg[0].Set((ushort)0xBEBE));
			Assert.Equal((ushort)0xBEBE, (ushort)arg[0]);

			Assert.Equal(AllJoyn.QStatus.OK, arg[0].Set((int)-9999));
			Assert.Equal((int)-9999, (int)arg[0]);

			Assert.Equal(AllJoyn.QStatus.OK, arg[0].Set((uint)0x32323232));
			Assert.Equal((uint)0x32323232, (uint)arg[0]);

			Assert.Equal(AllJoyn.QStatus.OK, arg[0].Set((long)-1));
			Assert.Equal((long)-1, (long)arg[0]);

			Assert.Equal(AllJoyn.QStatus.OK, arg[0].Set((ulong)0x6464646464646464));
			Assert.Equal((ulong)0x6464646464646464, (ulong)arg[0]);

			Assert.Equal(AllJoyn.QStatus.OK, arg[0].Set((float)1.61803f));
			Assert.Equal((float)1.61803f, (float)arg[0]);

			Assert.Equal(AllJoyn.QStatus.OK, arg[0].Set((double)3.14159265D));
			Assert.Equal((double)3.14159265D, (double)arg[0]);

			Assert.Equal(AllJoyn.QStatus.OK, arg[0].Set((string)"this is a string"));
			Assert.Equal("this is a string", (string)arg[0]);

			arg[0].ObjectPath = "/org/foo/bar";
			Assert.Equal("/org/foo/bar", arg[0].ObjectPath);

			// todo  no support for signature type
		}
コード例 #3
0
 public void SendChatSignal(string msg)
 {
     AllJoyn.MsgArgs payload = new AllJoyn.MsgArgs(1);
     payload[0].Set(msg);
     AllJoyn.QStatus status = Signal(null, currentSessionId, chatMember, payload, 0, 64);
     if(!status) {
         Debug.Log("Chat failed to send signal: "+status.ToString());
     }
 }
コード例 #4
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)
                {
                    Debug.Log("Server Ping: Error sending reply");
                }
            }
コード例 #5
0
ファイル: BasicClient.cs プロジェクト: GameClay/alljoyn_unity
        public string CallRemoteMethod()
        {
            using(AllJoyn.ProxyBusObject remoteObj = new AllJoyn.ProxyBusObject(sMsgBus, SERVICE_NAME, SERVICE_PATH, sSessionId))
            {
                AllJoyn.InterfaceDescription alljoynTestIntf = sMsgBus.GetInterface(INTERFACE_NAME);
                if(alljoynTestIntf == null)
                {
                    //throw new Exception("Client Failed to get test interface.");
                    return "";
                }
                else
                {
                    remoteObj.AddInterface(alljoynTestIntf);

                    AllJoyn.Message reply = new AllJoyn.Message(sMsgBus);
                    AllJoyn.MsgArgs inputs = new AllJoyn.MsgArgs(2);
                    inputs[0] = "Hello ";
                    inputs[1] = "World!";

                    AllJoyn.QStatus status = remoteObj.MethodCallSynch(SERVICE_NAME, "cat", inputs, reply, 5000, 0);

                    if(status)
                    {
                        //Debug.Log(SERVICE_NAME + ".cat(path=" + SERVICE_PATH + ") returned \"" + (string)reply[0] + "\"");
                        return (string)reply[0];
                    }
                    else
                    {
                        Debug.Log("MethodCall on " + SERVICE_NAME + ".cat failed");
                        return "";
                    }
                }
            }
        }
コード例 #6
0
ファイル: MsgArgsTest.cs プロジェクト: hybridgroup/alljoyn
		public void BasicArraySet()
		{
			AllJoyn.MsgArgs arg = new AllJoyn.MsgArgs(1);

			//byte
			byte[] in_byte_array = { 9, 19, 29, 39, 49 };
			arg[0].Set(in_byte_array);
			byte[] out_byte_array = (byte[])arg[0];
			Assert.Equal(in_byte_array.Length, out_byte_array.Length);
			for (int i = 0; i < out_byte_array.Length; i++)
			{
				Assert.Equal(in_byte_array[i], out_byte_array[i]);
			}

			//bool
			bool[] in_bool_array = { false, false, true, true, false };
			arg[0].Set(in_bool_array);
			bool[] out_bool_array = (bool[])arg[0];
			Assert.Equal(in_bool_array.Length, out_bool_array.Length);
			for (int i = 0; i < out_bool_array.Length; i++)
			{
				Assert.Equal(in_bool_array[i], out_bool_array[i]);
			}

			//short
			short[] in_short_array = { -9, -99, 999, 9999 };
			arg[0].Set(in_short_array);
			short[] out_short_array = (short[])arg[0];
			Assert.Equal(in_short_array.Length, out_short_array.Length);
			for (int i = 0; i < out_short_array.Length; i++)
			{
				Assert.Equal(in_short_array[i], out_short_array[i]);
			}

			//ushort
			ushort[] in_ushort_array = { 9, 99, 999, 9999 };
			arg[0].Set(in_ushort_array);
			ushort[] out_ushort_array = (ushort[])arg[0];
			Assert.Equal(in_ushort_array.Length, out_ushort_array.Length);
			for (int i = 0; i < out_short_array.Length; i++)
			{
				Assert.Equal(in_ushort_array[i], out_ushort_array[i]);
			}

			//int
			int[] in_int_array = { -8, -88, 888, 8888 };
			arg[0].Set(in_int_array);
			int[] out_int_array = (int[])arg[0];
			Assert.Equal(in_int_array.Length, out_int_array.Length);
			for (int i = 0; i < out_int_array.Length; i++)
			{
				Assert.Equal(in_int_array[i], out_int_array[i]);
			}

			//uint
			uint[] in_uint_array = { 8, 88, 888, 8888 };
			arg[0].Set(in_uint_array);
			uint[] out_uint_array = (uint[])arg[0];
			Assert.Equal(in_uint_array.Length, out_uint_array.Length);
			for (int i = 0; i < out_int_array.Length; i++)
			{
				Assert.Equal(in_uint_array[i], out_uint_array[i]);
			}

			//long
			long[] in_long_array = { -7, -77, 777, 7777 };
			arg[0].Set(in_long_array);
			long[] out_long_array = (long[])arg[0];
			Assert.Equal(in_long_array.Length, out_long_array.Length);
			for (int i = 0; i < out_long_array.Length; i++)
			{
				Assert.Equal(in_long_array[i], out_long_array[i]);
			}

			//ulong
			ulong[] in_ulong_array = { 7, 77, 777, 7777 };
			arg[0].Set(in_ulong_array);
			ulong[] out_ulong_array = (ulong[])arg[0];
			Assert.Equal(in_ulong_array.Length, out_ulong_array.Length);
			for (int i = 0; i < out_long_array.Length; i++)
			{
				Assert.Equal(in_ulong_array[i], out_ulong_array[i]);
			}

			//double
			double[] in_double_array = { 0.001, 0.01, 0.1, 1.0, 10.0, 100.0 };
			arg[0].Set(in_double_array);
			double[] out_double_array = (double[])arg[0];
			Assert.Equal(in_double_array.Length, out_double_array.Length);
			for (int i = 0; i < out_long_array.Length; i++)
			{
				Assert.Equal(in_double_array[i], out_double_array[i]);
			}

			//string
			string[] in_string_array = { "one", "two", "three", "four" };
			arg[0].Set(in_string_array);
			string[] out_string_array = (string[])arg[0];
			Assert.Equal(in_string_array.Length, out_string_array.Length);
			for (int i = 0; i < out_string_array.Length; i++)
			{
				Assert.Equal(in_string_array[i], out_string_array[i]);
			}
		}
コード例 #7
0
//Still test sending signals using obsolete Signal calls till the obsolete method is removed.
#pragma warning disable 618
			public void SendTestSignal2(String msg)
			{
				AllJoyn.MsgArgs payload = new AllJoyn.MsgArgs(1);
				payload[0].Set(msg);
				AllJoyn.QStatus status = Signal(null, 0, testSignalMember, payload, 0, 64);
				Assert.Equal(AllJoyn.QStatus.OK, status);
			}
コード例 #8
0
		public void TestAddMethodHandler()
		{
			AllJoyn.QStatus status = AllJoyn.QStatus.FAIL;

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

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

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

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

			status = testIntf.AddMember(AllJoyn.Message.Type.MethodCall, "ping", "s", "s", "in,out");
			Assert.Equal(AllJoyn.QStatus.OK, status);

			testIntf.Activate();

			// register bus listener
			AllJoyn.BusListener testBusListener = new TestBusListener(this);
			servicebus.RegisterBusListener(testBusListener);

			// create the bus object
			// the MethodTestBusObject constructor adds the interface & a handler for the ping method
			MethodTestBusObject methodTestBusObject = new MethodTestBusObject(servicebus, OBJECT_PATH);

			// register the bus object
			status = servicebus.RegisterBusObject(methodTestBusObject);
			Assert.Equal(AllJoyn.QStatus.OK, status);

			// request name
			nameOwnerChangedFlag = false;
			status = servicebus.RequestName(OBJECT_NAME, AllJoyn.DBus.NameFlags.ReplaceExisting | AllJoyn.DBus.NameFlags.DoNotQueue);
			Assert.Equal(AllJoyn.QStatus.OK, status);
			Wait(MaxWaitTime);
			Assert.Equal(true, nameOwnerChangedFlag);

			///////////////////////////////////////////////////////////

			// create the proxy bus object & call methods
			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+activate the interface
			AllJoyn.InterfaceDescription iFace = null;
			status = bus.CreateInterface(INTERFACE_NAME, out iFace);
			Assert.Equal(AllJoyn.QStatus.OK, status);
			Assert.NotNull(iFace);

			status = iFace.AddMember(AllJoyn.Message.Type.MethodCall, "ping", "s", "s", "in,out");
			Assert.Equal(AllJoyn.QStatus.OK, status);

			iFace.Activate();

			AllJoyn.ProxyBusObject proxyBusObject = new AllJoyn.ProxyBusObject(bus, OBJECT_NAME, OBJECT_PATH, 0);
			status = proxyBusObject.AddInterface(iFace);
			Assert.Equal(AllJoyn.QStatus.OK, status);

			AllJoyn.MsgArg input = new AllJoyn.MsgArg();
			input.Set("AllJoyn");
			AllJoyn.Message replyMsg = new AllJoyn.Message(bus);
			status = proxyBusObject.MethodCall(INTERFACE_NAME, "ping", input, replyMsg, 5000, 0);
			Assert.Equal(AllJoyn.QStatus.OK, status);
			Assert.Equal("AllJoyn", (string)replyMsg[0]);

//continue testing obsolete method calls till they are removed.
#pragma warning disable 618
			AllJoyn.MsgArg input1 = new AllJoyn.MsgArg();
			input1.Set("AllJoyn");
			AllJoyn.Message replyMsg1 = new AllJoyn.Message(bus);
			status = proxyBusObject.MethodCallSynch(INTERFACE_NAME, "ping", input1, replyMsg1, 5000, 0);
			Assert.Equal(AllJoyn.QStatus.OK, status);
			Assert.Equal("AllJoyn", (string)replyMsg1[0]);

			AllJoyn.MsgArgs input2 = new AllJoyn.MsgArgs(1);
			input2[0].Set("AllJoyn");
			AllJoyn.Message replyMsg2 = new AllJoyn.Message(bus);
			status = proxyBusObject.MethodCallSynch(INTERFACE_NAME, "ping", input2, replyMsg2, 5000, 0);
			Assert.Equal(AllJoyn.QStatus.OK, status);
			Assert.Equal("AllJoyn", (string)replyMsg2[0]);
#pragma warning restore 618

			methodTestBusObject.Dispose();
			servicebus.Dispose();

			// TODO: need to call dispose on proxyBusObject first otherwise you get an AccessViolation???
			proxyBusObject.Dispose();
			bus.Dispose();
		}
コード例 #9
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
			}
コード例 #10
0
ファイル: BasicClient.cs プロジェクト: GameClay/alljoyn_unity
        public string CallRemoteMethod()
        {
            using(AllJoyn.ProxyBusObject remoteObj = new AllJoyn.ProxyBusObject(sMsgBus, SERVICE_NAME, SERVICE_PATH, sSessionId))
            {
                AllJoyn.InterfaceDescription alljoynTestIntf = sMsgBus.GetInterface(INTERFACE_NAME);
                if(alljoynTestIntf == null)
                {
                    throw new Exception("Client Failed to get test interface.");
                }
                remoteObj.AddInterface(alljoynTestIntf);

                AllJoyn.Message reply = new AllJoyn.Message(sMsgBus);
                AllJoyn.MsgArgs inputs = new AllJoyn.MsgArgs(2);
                inputs[0] = "Hello ";
                inputs[1] = "World!";

                AllJoyn.QStatus status = remoteObj.MethodCallSynch(SERVICE_NAME, "cat", inputs, reply, 5000, 0);

                if(status)
                {
                    Console.WriteLine("{0}.{1} (path={2}) returned \"{3}\"", SERVICE_NAME, "cat", SERVICE_PATH,
                        (string)reply[0]);
                    return (string)reply[0];
                }
                else
                {
                    Console.WriteLine("MethodCall on {0}.{1} failed", SERVICE_NAME, "cat");
                    return "";
                }
            }
        }
コード例 #11
0
            public void SendData(double[] playerInput, double[] playerPos, double[] envData)
            {
                AllJoyn.MsgArgs payload = new AllJoyn.MsgArgs((uint)3);
                payload[0].Set((double[])playerInput);
                payload[1].Set ((double[])playerPos);
                payload[2].Set((double[])envData);

                AllJoyn.QStatus status = Signal(null, currentSessionId, vectorMember, payload, 0, 64);
                if (!status) {
                    DebugLog("RHR failed to send vector(data) signal: "+status.ToString());
                }
            }