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()); } }
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(""); } } }
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(""); } } } }
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"); }
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"); }
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); }
public string CallAcc(Vector3 vec) { using (AllJoyn.ProxyBusObject remoteObj = new AllJoyn.ProxyBusObject(msgBus, SERVICE_NAME, SERVICE_PATH, theSessionId)) { AllJoyn.InterfaceDescription alljoynTestIntf = msgBus.GetInterface(INTERFACE_NAME); if (alljoynTestIntf == null) { //throw new Exception("Client Failed to get test interface."); return("-1"); } else { remoteObj.AddInterface(alljoynTestIntf); AllJoyn.Message reply = new AllJoyn.Message(msgBus); //AllJoyn.MsgArgs inputs = new AllJoyn.MsgArgs(1); AllJoyn.MsgArg inputs = new AllJoyn.MsgArg(1); string str = vec.x + ";" + vec.y + ";" + vec.z; Debug.Log("kcwon CallAcc send String : " + str); inputs[0] = str; //AllJoyn.QStatus status = remoteObj.MethodCallSynch(SERVICE_NAME, "btn", inputs, reply, 5000, 0); AllJoyn.QStatus status = remoteObj.MethodCall(SERVICE_NAME, "acc", inputs, reply, 0, 0); if (status) { serverText += SERVICE_NAME + ".cat(path=" + SERVICE_PATH + ") returned \"" + (string)reply[0] + "\"\n"; Debug.Log(SERVICE_NAME + ".cat(path=" + SERVICE_PATH + ") returned \"" + (string)reply[0] + "\""); return((string)reply[0]); } else { serverText += "MethodCall on " + SERVICE_NAME + ".cat failed\n"; Debug.Log("MethodCall on " + SERVICE_NAME + ".cat failed"); return("-2"); } } } }
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"); }
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); } }
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); }
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()); }