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(); }
public ProxyBusObjectTest() { busAttachment = new AllJoyn.BusAttachment("ProxyBusObjectTest", false); Assert.Equal(AllJoyn.QStatus.OK, busAttachment.Start()); Assert.Equal(AllJoyn.QStatus.OK, busAttachment.Connect(AllJoynTestCommon.GetConnectSpec())); }
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(); }
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(); }
public void CreateDispose() { AllJoyn.BusAttachment busAttachment = new AllJoyn.BusAttachment("MessageTest", false); AllJoyn.Message message = new AllJoyn.Message(busAttachment); message.Dispose(); busAttachment.Dispose(); }
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); }
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) { Debug.Log("Client Interface Created."); testIntf.AddMember(AllJoyn.Message.Type.MethodCall, "cat", "ss", "s", "inStr1,inStr2,outStr"); testIntf.Activate(); } else { Debug.Log("Client Failed to create interface 'org.alljoyn.Bus.method_sample'"); } // Start the msg bus if(status) { status = sMsgBus.Start(); if(status) { Debug.Log("Client BusAttachment started."); } else { Debug.Log("Client BusAttachment.Start failed."); } } // Connect to the bus if(status) { status = sMsgBus.Connect(connectArgs); if(status) { Debug.Log("Client BusAttchement connected to " + connectArgs); } else { Debug.Log("Client BusAttachment::Connect(" + connectArgs + ") failed."); } } // Create a bus listener sBusListener = new MyBusListener(); if(status) { sMsgBus.RegisterBusListener(sBusListener); Debug.Log("Client BusListener Registered."); } }
public void Path() { 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.Path); }
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); }
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); }
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())); }
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(); }
// 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); }
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(); }
public MessageTest() { serviceBus = new AllJoyn.BusAttachment("MessageTest", false); Assert.NotNull(serviceBus); Assert.Equal(AllJoyn.QStatus.OK, serviceBus.Start()); Assert.Equal(AllJoyn.QStatus.OK, serviceBus.Connect(AllJoynTestCommon.GetConnectSpec())); //SetUp Client //start client BusAttachment clientBus = new AllJoyn.BusAttachment("MessageTestClient", true); Assert.Equal(AllJoyn.QStatus.OK, clientBus.Start()); Assert.Equal(AllJoyn.QStatus.OK, clientBus.Connect(AllJoynTestCommon.GetConnectSpec())); }
public void TestFoundLostAdvertisedName() { // 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; lostAdvertisedName = false; // register the bus listener AllJoyn.BusListener busListener = new TestBusListener(this); bus.RegisterBusListener(busListener); Wait(MaxWaitTime); Assert.Equal(true, listenerRegistered); // advertise the name, & see if we find it status = bus.FindAdvertisedName(ObjectName); Assert.Equal(AllJoyn.QStatus.OK, status); AllJoyn.SessionOpts sessionOpts = new AllJoyn.SessionOpts( AllJoyn.SessionOpts.TrafficType.Messages, false, AllJoyn.SessionOpts.ProximityType.Any, AllJoyn.TransportMask.Any); status = bus.AdvertiseName(ObjectName, sessionOpts.Transports); Assert.Equal(AllJoyn.QStatus.OK, status); Wait(MaxWaitTime); Assert.Equal(true, foundAdvertisedName); // stop advertising the name, & see if we lose it status = bus.CancelAdvertisedName(ObjectName, sessionOpts.Transports); Assert.Equal(AllJoyn.QStatus.OK, status); Wait(MaxWaitTime); Assert.Equal(true, lostAdvertisedName); // TODO: move these into a teardown method? busListener.Dispose(); bus.Dispose(); }
public void CreateInterface() { AllJoyn.QStatus status = AllJoyn.QStatus.FAIL; AllJoyn.BusAttachment bus = null; bus = new AllJoyn.BusAttachment("BusAttachmentTest", true); Assert.NotNull(bus); AllJoyn.InterfaceDescription testIntf = null; status = bus.CreateInterface("org.alljoyn.test.BusAttachment", out testIntf); Assert.Equal(AllJoyn.QStatus.OK, status); Assert.NotNull(testIntf); // TODO: move these into a teardown method? bus.Dispose(); }
public BusListenerTest() { notifyEvent = new AutoResetEvent(false); bus = new AllJoyn.BusAttachment("BusListenerTest", true); // 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); busListener = new TestBusListener(this); }
public void Connect_no_params() { AllJoyn.BusAttachment busAttachment = new AllJoyn.BusAttachment("BusAttachmentTest", true); Assert.NotNull(busAttachment); Assert.Equal(AllJoyn.QStatus.OK, busAttachment.Start()); Assert.Equal(AllJoyn.QStatus.OK, busAttachment.Connect()); Assert.True(busAttachment.IsConnected); Assert.True(busAttachment.ConnectSpec.Equals(AllJoynTestCommon.GetConnectSpec()) || busAttachment.ConnectSpec.Equals("null:")); busAttachment.Stop(); busAttachment.Join(); busAttachment.Dispose(); }
public AuthListenerTest() { serviceBus = new AllJoyn.BusAttachment("AuthListenerTestService", false); Assert.Equal(AllJoyn.QStatus.OK, serviceBus.Start()); Assert.Equal(AllJoyn.QStatus.OK, serviceBus.Connect(AllJoynTestCommon.GetConnectSpec())); AllJoyn.InterfaceDescription service_intf = null; Assert.Equal(AllJoyn.QStatus.OK, serviceBus.CreateInterface(INTERFACE_NAME, AllJoyn.InterfaceDescription.SecurityPolicy.Required, out service_intf)); Assert.Equal(AllJoyn.QStatus.OK, service_intf.AddMethod("ping", "s", "s", "in,out")); service_intf.Activate(); clientBus = new AllJoyn.BusAttachment("AuthListenerTestClient", false); Assert.Equal(AllJoyn.QStatus.OK, clientBus.Start()); Assert.Equal(AllJoyn.QStatus.OK, clientBus.Connect(AllJoynTestCommon.GetConnectSpec())); }
public void AddMember() { 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); bus.Dispose(); }
public BusObjectTest() { notifyEvent = new AutoResetEvent(false); // create+start+connect bus attachment 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+start+connect bus attachment 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); }
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 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 BasicServer() { // Create message bus msgBus = new AllJoyn.BusAttachment("myApp", true); // Add org.alljoyn.Bus.method_sample interface AllJoyn.QStatus status = msgBus.CreateInterface(INTERFACE_NAME, false, out testIntf); if(status) { Debug.Log("Server Interface Created."); testIntf.AddMember(AllJoyn.Message.Type.MethodCall, "cat", "ss", "s", "inStr1,inStr2,outStr"); testIntf.Activate(); } else { Debug.Log("Failed to create interface 'org.alljoyn.Bus.method_sample'"); } // Create a bus listener busListener = new MyBusListener(); if(status) { msgBus.RegisterBusListener(busListener); Debug.Log("Server BusListener Registered."); } // Set up bus object testObj = new TestBusObject(msgBus, SERVICE_PATH); // Start the msg bus if(status) { status = msgBus.Start(); if(status) { Debug.Log("Server BusAttachment started."); msgBus.RegisterBusObject(testObj); status = msgBus.Connect(connectArgs); if(status) { Debug.Log("Server BusAttchement connected to " + connectArgs); } else { Debug.Log("Server BusAttachment::Connect(" + connectArgs + ") failed."); } } else { Debug.Log("Server BusAttachment.Start failed."); } } // Request name if(status) { status = msgBus.RequestName(SERVICE_NAME, AllJoyn.DBus.NameFlags.ReplaceExisting | AllJoyn.DBus.NameFlags.DoNotQueue); if(!status) { Debug.Log("Server RequestName(" + SERVICE_NAME + ") failed (status=" + status + ")"); } } // Create session AllJoyn.SessionOpts opts = new AllJoyn.SessionOpts(AllJoyn.SessionOpts.TrafficType.Messages, false, AllJoyn.SessionOpts.ProximityType.Any, AllJoyn.TransportMask.Any); if(status) { ushort sessionPort = SERVICE_PORT; sessionPortListener = new MySessionPortListener(); status = msgBus.BindSessionPort(ref sessionPort, opts, sessionPortListener); if(!status || sessionPort != SERVICE_PORT) { Debug.Log("Server BindSessionPort failed (" + status + ")"); } } // Advertise name if(status) { status = msgBus.AdvertiseName(SERVICE_NAME, opts.Transports); if(!status) { Debug.Log("Server Failed to advertise name " + SERVICE_NAME + " (" + status + ")"); } } }
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 }
public void StartUp() { chatText = "Starting AllJoyn\n\n\n" + chatText; AllJoynStarted = true; AllJoyn.QStatus status = AllJoyn.QStatus.OK; { chatText = "Creating BusAttachment\n" + chatText; // Create message bus msgBus = new AllJoyn.BusAttachment("myApp", true); // Add org.alljoyn.Bus.method_sample interface status = msgBus.CreateInterface(INTERFACE_NAME, false, out testIntf); if(status) { chatText = "Chat Interface Created.\n" + chatText; Debug.Log("Chat Interface Created."); testIntf.AddSignal("chat", "s", "msg", 0); testIntf.Activate(); } else { chatText = "Failed to create interface 'org.alljoyn.Bus.chat'\n" + chatText; Debug.Log("Failed to create interface 'org.alljoyn.Bus.chat'"); } // Create a bus listener busListener = new MyBusListener(); if(status) { msgBus.RegisterBusListener(busListener); chatText = "Chat BusListener Registered.\n" + chatText; Debug.Log("Chat BusListener Registered."); } if(testObj == null) testObj = new TestBusObject(msgBus, SERVICE_PATH); // Start the msg bus if(status) { status = msgBus.Start(); if(status) { chatText = "Chat BusAttachment started.\n" + chatText; Debug.Log("Chat BusAttachment started."); msgBus.RegisterBusObject(testObj); for (int i = 0; i < connectArgs.Length; ++i) { chatText = "Chat Connect trying: "+connectArgs[i]+"\n" + chatText; Debug.Log("Chat Connect trying: "+connectArgs[i]); status = msgBus.Connect(connectArgs[i]); if (status) { chatText = "BusAttchement.Connect(" + connectArgs[i] + ") SUCCEDED.\n" + chatText; Debug.Log("BusAttchement.Connect(" + connectArgs[i] + ") SUCCEDED."); connectedVal = connectArgs[i]; break; } else { chatText = "BusAttachment.Connect(" + connectArgs[i] + ") failed.\n" + chatText; Debug.Log("BusAttachment.Connect(" + connectArgs[i] + ") failed."); } } if(!status) { chatText = "BusAttachment.Connect failed.\n" + chatText; Debug.Log("BusAttachment.Connect failed."); } } else { chatText = "Chat BusAttachment.Start failed.\n" + chatText; Debug.Log("Chat BusAttachment.Start failed."); } } myAdvertisedName = SERVICE_NAME+"._"+msgBus.GlobalGUIDString; AllJoyn.InterfaceDescription.Member chatMember = testIntf.GetMember("chat"); status = msgBus.RegisterSignalHandler(this.ChatSignalHandler, chatMember, null); if(!status) { chatText ="Chat Failed to add signal handler " + status + "\n" + chatText; Debug.Log("Chat Failed to add signal handler " + status); } else { chatText ="Chat add signal handler " + status + "\n" + chatText; Debug.Log("Chat add signal handler " + status); } status = msgBus.AddMatch("type='signal',member='chat'"); if(!status) { chatText ="Chat Failed to add Match " + status.ToString() + "\n" + chatText; Debug.Log("Chat Failed to add Match " + status.ToString()); } else { chatText ="Chat add Match " + status.ToString() + "\n" + chatText; Debug.Log("Chat add Match " + status.ToString()); } } // Request name if(status) { status = msgBus.RequestName(myAdvertisedName, AllJoyn.DBus.NameFlags.ReplaceExisting | AllJoyn.DBus.NameFlags.DoNotQueue); if(!status) { chatText ="Chat RequestName(" + SERVICE_NAME + ") failed (status=" + status + ")\n" + chatText; Debug.Log("Chat RequestName(" + SERVICE_NAME + ") failed (status=" + status + ")"); } } // Create session opts = new AllJoyn.SessionOpts(AllJoyn.SessionOpts.TrafficType.Messages, false, AllJoyn.SessionOpts.ProximityType.Any, AllJoyn.TransportMask.Any); if(status) { ushort sessionPort = SERVICE_PORT; sessionPortListener = new MySessionPortListener(); status = msgBus.BindSessionPort(ref sessionPort, opts, sessionPortListener); if(!status || sessionPort != SERVICE_PORT) { chatText = "Chat BindSessionPort failed (" + status + ")\n" + chatText; Debug.Log("Chat BindSessionPort failed (" + status + ")"); } chatText = "Chat BindSessionPort on port (" + sessionPort + ")\n" + chatText; Debug.Log("Chat BBindSessionPort on port (" + sessionPort + ")");; } // Advertise name if(status) { status = msgBus.AdvertiseName(myAdvertisedName, opts.Transports); if(!status) { chatText = "Chat Failed to advertise name " + myAdvertisedName + " (" + status + ")\n" + chatText; Debug.Log("Chat Failed to advertise name " + myAdvertisedName + " (" + status + ")"); } } status = msgBus.FindAdvertisedName(SERVICE_NAME); if(!status) { chatText = "Chat org.alljoyn.Bus.FindAdvertisedName failed.\n" + chatText; Debug.Log("Chat org.alljoyn.Bus.FindAdvertisedName failed."); } Debug.Log("Completed ChatService Constructor"); }
public BasicServer() { // Create message bus msgBus = new AllJoyn.BusAttachment("myApp", true); // Add org.alljoyn.Bus.method_sample interface AllJoyn.QStatus status = msgBus.CreateInterface(INTERFACE_NAME, out testIntf); if(status) { Console.WriteLine("Server 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'"); } // Create a bus listener busListener = new MyBusListener(); if(status) { msgBus.RegisterBusListener(busListener); Console.WriteLine("Server BusListener Registered."); } // Set up bus object testObj = new TestBusObject(msgBus, SERVICE_PATH); // Start the msg bus if(status) { status = msgBus.Start(); if(status) { Console.WriteLine("Server BusAttachment started."); msgBus.RegisterBusObject(testObj); for (int i = 0; i < connectArgs.Length; ++i) { status = msgBus.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."); } } else { Console.WriteLine("Server BusAttachment.Start failed."); } } // Request name if(status) { status = msgBus.RequestName(SERVICE_NAME, AllJoyn.DBus.NameFlags.ReplaceExisting | AllJoyn.DBus.NameFlags.DoNotQueue); if(!status) { Console.WriteLine("Server RequestName({0}) failed (status={1})", SERVICE_NAME, status); } } // Create session AllJoyn.SessionOpts opts = new AllJoyn.SessionOpts(AllJoyn.SessionOpts.TrafficType.Messages, false, AllJoyn.SessionOpts.ProximityType.Any, AllJoyn.TransportMask.Any); if(status) { ushort sessionPort = SERVICE_PORT; sessionPortListener = new MySessionPortListener(); status = msgBus.BindSessionPort(ref sessionPort, opts, sessionPortListener); if(!status || sessionPort != SERVICE_PORT) { Console.WriteLine("Server BindSessionPort failed ({0})", status); } } // Advertise name if(status) { status = msgBus.AdvertiseName(SERVICE_NAME, opts.Transports); if(!status) { Console.WriteLine("Server Failed to advertise name {0} ({1})", SERVICE_NAME, status); } } Console.WriteLine("Should have setup server"); }
public void SetCredentials() { AllJoyn.BusAttachment busAttachment = new AllJoyn.BusAttachment("PasswordManagerTest", false); Assert.Equal(AllJoyn.QStatus.OK, AllJoyn.PasswordManager.SetCredentials("ALLJOYN_PIN_KEYX", "1234")); busAttachment.Dispose(); }
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, 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) { 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("Client BusListener Registered."); } }