public void GetArgs() { //SetUp Service //start service BusAttachment AllJoyn.BusAttachment serviceBus = new AllJoyn.BusAttachment("MessageTestService", true); Assert.Equal(AllJoyn.QStatus.OK, serviceBus.Start()); Assert.Equal(AllJoyn.QStatus.OK, serviceBus.Connect(AllJoynTestCommon.GetConnectSpec())); TestBusListener testBusListener = new TestBusListener(this); serviceBus.RegisterBusListener(testBusListener); //Create and activate the service Interface AllJoyn.InterfaceDescription testIntf = null; Assert.Equal(AllJoyn.QStatus.OK, serviceBus.CreateInterface(INTERFACE_NAME, out testIntf)); Assert.NotNull(testIntf); Assert.Equal(AllJoyn.QStatus.OK, testIntf.AddMember(AllJoyn.Message.Type.MethodCall, "ping", "s", "s", "in,out")); testIntf.Activate(); //create and register BusObject MessageTestBusObject busObj = new MessageTestBusObject(OBJECT_PATH); busObj.AddInterface(testIntf); AllJoyn.InterfaceDescription.Member ping; ping = testIntf.GetMember("ping"); Assert.NotNull(ping); Assert.Equal(AllJoyn.QStatus.OK, busObj.AddMethodHandler(ping, busObj.Ping)); Assert.Equal(AllJoyn.QStatus.OK, serviceBus.RegisterBusObject(busObj)); _nameOwnerChangedFlag = false; Assert.Equal(AllJoyn.QStatus.OK, serviceBus.RequestName(WELLKNOWN_NAME, AllJoyn.DBus.NameFlags.ReplaceExisting | AllJoyn.DBus.NameFlags.DoNotQueue | AllJoyn.DBus.NameFlags.AllowReplacement)); Wait(TimeSpan.FromSeconds(2)); Assert.True(_nameOwnerChangedFlag); //SetUp Client //start client BusAttachment AllJoyn.BusAttachment clientBus = new AllJoyn.BusAttachment("MessageTestClient", true); Assert.Equal(AllJoyn.QStatus.OK, clientBus.Start()); Assert.Equal(AllJoyn.QStatus.OK, clientBus.Connect(AllJoynTestCommon.GetConnectSpec())); AllJoyn.ProxyBusObject proxyObj = new AllJoyn.ProxyBusObject(clientBus, WELLKNOWN_NAME, OBJECT_PATH, 0); Assert.Equal(AllJoyn.QStatus.OK, proxyObj.IntrospectRemoteObject()); AllJoyn.Message reply = new AllJoyn.Message(clientBus); AllJoyn.MsgArg input = new AllJoyn.MsgArg("s", "AllJoyn"); proxyObj.MethodCall(INTERFACE_NAME, "ping", input, reply, 25000, 0); //Actual tests for GetArg/GetArgs // call using GetArg specifying the array index Assert.Equal("AllJoyn", (string)reply.GetArg(0)); // use the this[] operator call to get the MsgArg Assert.Equal("AllJoyn", (string)(reply[0])); // Return the MsgArgs note could be multiple values AllJoyn.MsgArg replyArg = reply.GetArgs(); Assert.Equal(1, replyArg.Length); Assert.Equal("AllJoyn", (string)replyArg); // Parse the Message Drectly object replyString; Assert.Equal(AllJoyn.QStatus.OK, reply.GetArgs("s", out replyString)); Assert.Equal("AllJoyn", (string)replyString); serviceBus.UnregisterBusListener(testBusListener); reply.Dispose(); input.Dispose(); proxyObj.Dispose(); clientBus.Dispose(); testBusListener.Dispose(); busObj.Dispose(); serviceBus.Dispose(); }
public void Properties() { //SetUp Service //start service BusAttachment AllJoyn.BusAttachment serviceBus = new AllJoyn.BusAttachment("MessageTestService", true); Assert.Equal(AllJoyn.QStatus.OK, serviceBus.Start()); Assert.Equal(AllJoyn.QStatus.OK, serviceBus.Connect(AllJoynTestCommon.GetConnectSpec())); TestBusListener testBusListener = new TestBusListener(this); serviceBus.RegisterBusListener(testBusListener); //Create and activate the service Interface AllJoyn.InterfaceDescription testIntf = null; Assert.Equal(AllJoyn.QStatus.OK, serviceBus.CreateInterface(INTERFACE_NAME, out testIntf)); Assert.NotNull(testIntf); Assert.Equal(AllJoyn.QStatus.OK, testIntf.AddMember(AllJoyn.Message.Type.MethodCall, "ping", "s", "s", "in,out")); testIntf.Activate(); //create and register BusObject MessageTestBusObject busObj = new MessageTestBusObject(OBJECT_PATH); busObj.AddInterface(testIntf); AllJoyn.InterfaceDescription.Member ping; ping = testIntf.GetMember("ping"); Assert.NotNull(ping); Assert.Equal(AllJoyn.QStatus.OK, busObj.AddMethodHandler(ping, busObj.Ping)); Assert.Equal(AllJoyn.QStatus.OK, serviceBus.RegisterBusObject(busObj)); _nameOwnerChangedFlag = false; Assert.Equal(AllJoyn.QStatus.OK, serviceBus.RequestName(WELLKNOWN_NAME, AllJoyn.DBus.NameFlags.ReplaceExisting | AllJoyn.DBus.NameFlags.DoNotQueue | AllJoyn.DBus.NameFlags.AllowReplacement)); Wait(TimeSpan.FromSeconds(2)); Assert.True(_nameOwnerChangedFlag); // SetUp Client // start client BusAttachment AllJoyn.BusAttachment clientBus = new AllJoyn.BusAttachment("MessageTestClient", true); Assert.Equal(AllJoyn.QStatus.OK, clientBus.Start()); Assert.Equal(AllJoyn.QStatus.OK, clientBus.Connect(AllJoynTestCommon.GetConnectSpec())); AllJoyn.ProxyBusObject proxyObj = new AllJoyn.ProxyBusObject(clientBus, INTERFACE_NAME, OBJECT_PATH, 0); Assert.Equal(AllJoyn.QStatus.OK, proxyObj.IntrospectRemoteObject()); AllJoyn.Message reply = new AllJoyn.Message(clientBus); AllJoyn.MsgArg input = new AllJoyn.MsgArg("s", "AllJoyn"); proxyObj.MethodCall(INTERFACE_NAME, "ping", input, reply, 25000, 0); // Actual tests for GetArg/GetArgs // check the message properties Assert.False(reply.IsBroadcastSignal); Assert.False(reply.IsGlobalBroadcast); Assert.False(reply.IsSessionless); Assert.False(reply.IsExpired()); uint timeLeft; reply.IsExpired(out timeLeft); Assert.True(timeLeft > 0); Assert.False(reply.IsUnreliable); Assert.False(reply.IsEncrypted); // we don't expect any flags Assert.Equal((byte)0, reply.Flags); // no security is being used so there should be no security mechanism Assert.Equal("", reply.AuthMechanism); Assert.Equal(AllJoyn.Message.Type.MethodReturn, reply.MessageType); // The serial is unknown before hand but it should not be zero Assert.NotEqual<uint>(0u, reply.CallSerial); Assert.NotEqual<uint>(0u, reply.ReplySerial); // A method return does not have an Object Path Assert.Equal("", reply.ObjectPath); // A method return does not have an interface specified Assert.Equal("", reply.Interface); // The member name is not specified on a message return Assert.Equal("", reply.MemberName); // TODO possible error the documentation for Sender states it should // be returning the well-known name however in this case it is // returning the unique name of the sender. Assert.Equal(serviceBus.UniqueName, reply.Sender); Assert.Equal(clientBus.UniqueName, reply.ReceiveEndPointName); Assert.Equal(clientBus.UniqueName, reply.Destination); Assert.Equal(0u, reply.CompressionToken); // no session set up for this test Session Id should be 0 Assert.Equal(0u, reply.SessionId); String errorMsg; // TODO produce test that generates actual error Message Assert.Null(reply.GetErrorName(out errorMsg)); Assert.Equal("", errorMsg); // The ToString method only returns a string when running debug code #if DEBUG Assert.True(reply.ToString().StartsWith("<message endianness=")); Assert.True(reply.ToString().Contains("<header field=\"REPLY_SERIAL\">")); Assert.True(reply.ToString().Contains("<header field=\"DESTINATION\">")); Assert.True(reply.ToString().Contains("<header field=\"SENDER\">")); Assert.True(reply.ToString().Contains("<header field=\"SIGNATURE\">")); Assert.True(reply.ToString().Contains("<signature>s</signature>")); Assert.True(reply.ToString().Contains("<string>AllJoyn</string>")); Assert.True(reply.ToString().EndsWith("</message>")); // this call to description should return 'METHID_RET[<reply serial>](s)' Assert.True(reply.Description.StartsWith("METHOD_RET[")); #else Assert.Equal("", reply.ToString()); Assert.Equal("", reply.Description); #endif // TODO figure out a good way to test the TimeStamp property //reply.TimeStamp // CleanUp serviceBus.UnregisterBusListener(testBusListener); reply.Dispose(); input.Dispose(); proxyObj.Dispose(); clientBus.Dispose(); testBusListener.Dispose(); busObj.Dispose(); serviceBus.Dispose(); }
public void rsa_keyx() { ResetAuthFlags(); clientBus.ClearKeyStore(); PinKeyX_service_authlistener serviceAuthlistener = new PinKeyX_service_authlistener(this); Assert.Equal(AllJoyn.QStatus.OK, serviceBus.EnablePeerSecurity("ALLJOYN_RSA_KEYX", serviceAuthlistener, null, false)); serviceBus.ClearKeyStore(); Assert.Equal(AllJoyn.QStatus.OK, SetUpAuthService()); PinKeyX_client_authlistener clientAuthlistener = new PinKeyX_client_authlistener(this); Assert.Equal(AllJoyn.QStatus.OK, clientBus.EnablePeerSecurity("ALLJOYN_RSA_KEYX", clientAuthlistener, null, false)); clientBus.ClearKeyStore(); // create+activate the interface AllJoyn.QStatus status; AllJoyn.InterfaceDescription iFace = null; Assert.Equal(AllJoyn.QStatus.OK, clientBus.CreateInterface(INTERFACE_NAME, AllJoyn.InterfaceDescription.SecurityPolicy.Required, out iFace)); Assert.NotNull(iFace); Assert.Equal(AllJoyn.QStatus.OK, iFace.AddMethod("ping", "s", "s", "in,out")); iFace.Activate(); AllJoyn.ProxyBusObject proxyBusObject = new AllJoyn.ProxyBusObject(clientBus, WELLKNOWN_NAME, OBJECT_PATH, 0); Assert.NotNull(proxyBusObject); Assert.Equal(AllJoyn.QStatus.OK, proxyBusObject.AddInterface(iFace)); AllJoyn.MsgArg input = new AllJoyn.MsgArg("s", "AllJoyn"); AllJoyn.Message replyMsg = new AllJoyn.Message(clientBus); status = proxyBusObject.MethodCall(INTERFACE_NAME, "ping", input, replyMsg, 5000, 0); Assert.Equal(AllJoyn.QStatus.OK, status); Assert.Equal("AllJoyn", (string)replyMsg[0]); Assert.True(authflags.requestCreds_service); Assert.True(authflags.authComplete_serivce); Assert.True(authflags.verifyCreds_service); Assert.True(authflags.requestCreds_client); Assert.True(authflags.authComplete_client); Assert.True(authflags.verifyCreds_client); clientAuthlistener.Dispose(); serviceAuthlistener.Dispose(); busObject.Dispose(); proxyBusObject.Dispose(); Assert.Equal(AllJoyn.QStatus.OK, serviceBus.Stop()); Assert.Equal(AllJoyn.QStatus.OK, serviceBus.Join()); Assert.Equal(AllJoyn.QStatus.OK, clientBus.Stop()); Assert.Equal(AllJoyn.QStatus.OK, clientBus.Join()); serviceBus.Dispose(); clientBus.Dispose(); }
public void srp_keyx2() { ResetAuthFlags(); clientBus.ClearKeyStore(); SrpKeyx2_service_authlistener serviceAuthlistener = new SrpKeyx2_service_authlistener(this); Assert.Equal(AllJoyn.QStatus.OK, serviceBus.EnablePeerSecurity("ALLJOYN_SRP_KEYX", serviceAuthlistener, null, false)); serviceBus.ClearKeyStore(); Assert.Equal(AllJoyn.QStatus.OK, SetUpAuthService()); SrpKeyx2_client_authlistener clientAuthlistener = new SrpKeyx2_client_authlistener(this); Assert.Equal(AllJoyn.QStatus.OK, clientBus.EnablePeerSecurity("ALLJOYN_SRP_KEYX", clientAuthlistener, null, false)); clientBus.ClearKeyStore(); // create+activate the interface AllJoyn.QStatus status; AllJoyn.InterfaceDescription iFace = null; Assert.Equal(AllJoyn.QStatus.OK, clientBus.CreateInterface(INTERFACE_NAME, AllJoyn.InterfaceDescription.SecurityPolicy.Required, out iFace)); Assert.NotNull(iFace); Assert.Equal(AllJoyn.QStatus.OK, iFace.AddMethod("ping", "s", "s", "in,out")); iFace.Activate(); AllJoyn.ProxyBusObject proxyBusObject = new AllJoyn.ProxyBusObject(clientBus, WELLKNOWN_NAME, OBJECT_PATH, 0); Assert.NotNull(proxyBusObject); Assert.Equal(AllJoyn.QStatus.OK, proxyBusObject.AddInterface(iFace)); AllJoyn.MsgArg input = new AllJoyn.MsgArg("s", "AllJoyn"); AllJoyn.Message replyMsg = new AllJoyn.Message(clientBus); status = proxyBusObject.MethodCall(INTERFACE_NAME, "ping", input, replyMsg, 5000, 0); Assert.Equal(AllJoyn.QStatus.BUS_REPLY_IS_ERROR_MESSAGE, status); Assert.True(authflags.requestCreds_service); Assert.True(authflags.authComplete_serivce); Assert.True(authflags.authComplete_client); // Authentication complete can occure before the SecurityViolation callback // with authentication complete the MethodCall will return the BUS_REPLY_IS_ERROR_MESSAGE // and the code could check for the sercurityViolation_client before it is actually set // for this reason we need to wait for the flag to be set. Wait(TimeSpan.FromSeconds(5)); Assert.True(authflags.securityViolation_client); clientAuthlistener.Dispose(); serviceAuthlistener.Dispose(); busObject.Dispose(); proxyBusObject.Dispose(); Assert.Equal(AllJoyn.QStatus.OK, serviceBus.Stop()); Assert.Equal(AllJoyn.QStatus.OK, serviceBus.Join()); Assert.Equal(AllJoyn.QStatus.OK, clientBus.Stop()); Assert.Equal(AllJoyn.QStatus.OK, clientBus.Join()); serviceBus.Dispose(); clientBus.Dispose(); }
public AllJoyn.QStatus SetUpAuthClient() { AllJoyn.QStatus status = AllJoyn.QStatus.FAIL; AllJoyn.ProxyBusObject proxyObj = new AllJoyn.ProxyBusObject(clientBus, WELLKNOWN_NAME, OBJECT_PATH, 0); status = proxyObj.IntrospectRemoteObject(); if (!status) { return status; } AllJoyn.Message reply = new AllJoyn.Message(clientBus); AllJoyn.MsgArg input = new AllJoyn.MsgArg("s", "AllJoyn"); Console.WriteLine(proxyObj.GetInterface(INTERFACE_NAME).Introspect()); status = proxyObj.MethodCall(INTERFACE_NAME, "ping", input, reply, 5000, 0); if (!status) { return status; } if ((string)reply[0] != "AllJoyn") { Console.WriteLine((string)reply[0] + " != \"AllJoyn\" as expected"); return AllJoyn.QStatus.FAIL; } return status; }
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.MsgArg inputs = new AllJoyn.MsgArg(2); inputs[0] = "Hello "; inputs[1] = "World!"; AllJoyn.QStatus status = remoteObj.MethodCall(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 ""; } } }
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(); }
public static void Main(string[] args) { Console.WriteLine("AllJoyn Library version: " + AllJoyn.GetVersion()); Console.WriteLine("AllJoyn Library buildInfo: " + AllJoyn.GetBuildInfo()); // 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, out testIntf); if(status) { Console.WriteLine("Interface Created."); testIntf.AddMember(AllJoyn.Message.Type.MethodCall, "cat", "ss", "s", "inStr1,inStr2,outStr"); testIntf.Activate(); } else { Console.WriteLine("Failed to create interface 'org.alljoyn.Bus.method_sample'"); } // Start the msg bus if(status) { status = sMsgBus.Start(); if(status) { Console.WriteLine("BusAttachment started."); } else { Console.WriteLine("BusAttachment.Start failed."); } } // Connect to the bus if(status) { for (int i = 0; i < connectArgs.Length; ++i) { status = sMsgBus.Connect(connectArgs[i]); if (status) { Console.WriteLine("BusAttchement.Connect(" + connectArgs[i] + ") SUCCEDED."); break; } else { Console.WriteLine("BusAttachment.Connect(" + connectArgs[i] + ") failed."); } } if(!status) { Console.WriteLine("BusAttachment.Connect failed."); } } // Create a bus listener sBusListener = new MyBusListener(); if(status) { sMsgBus.RegisterBusListener(sBusListener); Console.WriteLine("BusListener Registered."); } // Begin discovery on the well-known name of the service to be called if(status) { status = sMsgBus.FindAdvertisedName(SERVICE_NAME); if(!status) { Console.WriteLine("org.alljoyn.Bus.FindAdvertisedName failed."); } } // Wait for join session to complete while(sJoinComplete == false) { System.Threading.Thread.Sleep(1); } if(status) { 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("Failed to get test interface."); } remoteObj.AddInterface(alljoynTestIntf); AllJoyn.Message reply = new AllJoyn.Message(sMsgBus); AllJoyn.MsgArg inputs = new AllJoyn.MsgArg(2); inputs[0] = "Hello "; inputs[1] = "World!"; status = remoteObj.MethodCall(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]); } else { Console.WriteLine("MethodCall on {0}.{1} failed", SERVICE_NAME, "cat"); } } } // Dispose of objects now sMsgBus.Dispose(); sBusListener.Dispose(); Console.WriteLine("basic client exiting with status {0} ({1})\n", status, status.ToString()); }
public void MethodNoInputParams() { // 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, "ding", "", "s", "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 dingBusObject constructor adds the interface & a handler for the ping method DingBusObject dingBusObject = new DingBusObject(servicebus, OBJECT_PATH); // register the bus object status = servicebus.RegisterBusObject(dingBusObject); Assert.Equal(AllJoyn.QStatus.OK, status); // request name nameOwnerChangedFlag = false; status = servicebus.RequestName(OBJECT_NAME, AllJoyn.DBus.NameFlags.ReplaceExisting | AllJoyn.DBus.NameFlags.DoNotQueue | AllJoyn.DBus.NameFlags.AllowReplacement); Assert.Equal(AllJoyn.QStatus.OK, status); Wait(MaxWaitTime); Assert.Equal(true, nameOwnerChangedFlag); /////////////////////////////////////////////////////////// // 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.AddMethod("ding", "", "s", "in,out"); Assert.Equal(AllJoyn.QStatus.OK, status); iFace.Activate(); proxyBusObject = new AllJoyn.ProxyBusObject(bus, OBJECT_NAME, OBJECT_PATH, 0); status = proxyBusObject.AddInterface(iFace); Assert.Equal(AllJoyn.QStatus.OK, status); AllJoyn.Message replyMsg = new AllJoyn.Message(bus); status = proxyBusObject.MethodCall(INTERFACE_NAME, "ding", AllJoyn.MsgArg.Zero, replyMsg, 5000, 0); Assert.Equal(AllJoyn.QStatus.OK, status); Assert.Equal("Hello from Ding.", (string)replyMsg[0]); //continue testing obsolete method calls till they are removed. #pragma warning disable 618 AllJoyn.Message replyMsg1 = new AllJoyn.Message(bus); status = proxyBusObject.MethodCallSynch(INTERFACE_NAME, "ding", AllJoyn.MsgArg.Zero, replyMsg1, 5000, 0); Assert.Equal(AllJoyn.QStatus.OK, status); Assert.Equal("Hello from Ding.", (string)replyMsg1[0]); AllJoyn.Message replyMsg2 = new AllJoyn.Message(bus); status = proxyBusObject.MethodCallSynch(INTERFACE_NAME, "ding", AllJoyn.MsgArg.Zero, replyMsg2, 5000, 0); Assert.Equal(AllJoyn.QStatus.OK, status); Assert.Equal("Hello from Ding.", (string)replyMsg2[0]); #pragma warning restore 618 dingBusObject.Dispose(); }