Пример #1
0
        public void AddInterfaceTest()
        {
            BusAttachment bus = new BusAttachment("addinterface", true, 4);

            bus.CreateInterfacesFromXml(signalIntf);
            bus.CreateInterfacesFromXml(methodIntf);
            bus.CreateInterfacesFromXml(propertyIntf);
            bus.CreateInterfacesFromXml(mixedIntf);
            bus.CreateInterfacesFromXml(emptyIntf);
            InterfaceDescription[] annIntf = new InterfaceDescription[1];
            bus.CreateInterface("org.alljoyn.Annotated", annIntf, false);
            annIntf[0].AddMethod("method", "ss", "s", "in1,in2,out1", (byte)0, "");
            annIntf[0].AddProperty("property", "s", (byte)PropAccessType.PROP_ACCESS_RW);
            annIntf[0].AddSignal("signal", "suy", "str,uint,byte", (byte)0, "");
            annIntf[0].AddAnnotation("org.freedesktop.DBus.Deprecated", "false");
            annIntf[0].AddMemberAnnotation("method", "org.freedesktop.DBus.Method.NoReply", "true");
            annIntf[0].AddPropertyAnnotation("property", "org.freedesktop.DBus.Property.EmitsChangedSignal", "true");
            annIntf[0].Activate();

            BusObject busObj = new BusObject(bus, "/addinterfaces", false);

            busObj.AddInterface(bus.GetInterface("org.alljoyn.Signals"));
            busObj.AddInterface(bus.GetInterface("org.alljoyn.Methods"));
            busObj.AddInterface(bus.GetInterface("org.alljoyn.Properties"));
            busObj.AddInterface(bus.GetInterface("org.alljoyn.Empty"));
            busObj.AddInterface(bus.GetInterface("org.alljoyn.Annotated"));
        }
Пример #2
0
        public void AddInterfaceTest()
        {
            BusAttachment bus = new BusAttachment("addinterface", true, 4);
            bus.CreateInterfacesFromXml(signalIntf);
            bus.CreateInterfacesFromXml(methodIntf);
            bus.CreateInterfacesFromXml(propertyIntf);
            bus.CreateInterfacesFromXml(mixedIntf);
            bus.CreateInterfacesFromXml(emptyIntf);
            InterfaceDescription[] annIntf = new InterfaceDescription[1];
            bus.CreateInterface("org.alljoyn.Annotated", annIntf, false);
            annIntf[0].AddMethod("method", "ss", "s", "in1,in2,out1", (byte)0, "");
            annIntf[0].AddProperty("property", "s", (byte)PropAccessType.PROP_ACCESS_RW);
            annIntf[0].AddSignal("signal", "suy", "str,uint,byte", (byte)0, "");
            annIntf[0].AddAnnotation("org.freedesktop.DBus.Deprecated", "false");
            annIntf[0].AddMemberAnnotation("method", "org.freedesktop.DBus.Method.NoReply", "true");
            annIntf[0].AddPropertyAnnotation("property", "org.freedesktop.DBus.Property.EmitsChangedSignal", "true");
            annIntf[0].Activate();

            BusObject busObj = new BusObject(bus, "/addinterfaces", false);
            busObj.AddInterface(bus.GetInterface("org.alljoyn.Signals"));
            busObj.AddInterface(bus.GetInterface("org.alljoyn.Methods"));
            busObj.AddInterface(bus.GetInterface("org.alljoyn.Properties"));
            busObj.AddInterface(bus.GetInterface("org.alljoyn.Empty"));
            busObj.AddInterface(bus.GetInterface("org.alljoyn.Annotated"));
        }
Пример #3
0
        public void CreateInterfacesFromXMLTest()
        {
            BusAttachment bus = new BusAttachment("xmlinterfaces", true, 4);

            bus.CreateInterfacesFromXml(signalIntf);
            bus.CreateInterfacesFromXml(methodIntf);
            bus.CreateInterfacesFromXml(propertyIntf);
            bus.CreateInterfacesFromXml(mixedIntf);
            InterfaceDescription i = bus.GetInterface("org.alljoyn.Signals");

            Assert.IsNotNull(i);
            Assert.IsNotNull(bus.GetInterface("org.alljoyn.Methods"));
            Assert.IsNotNull(bus.GetInterface("org.alljoyn.Properties"));
            Assert.IsNotNull(bus.GetInterface("org.alljoyn.Mixed"));
            InterfaceDescription[] intfs = new InterfaceDescription[14];
            bus.GetInterfaces(intfs);
            Assert.IsNotNull(intfs[0]);
            Assert.IsNotNull(intfs[1]);
            Assert.IsNotNull(intfs[2]);
            Assert.IsNotNull(intfs[3]);

            // BUGBUG: DeleteInterface is throwing an exception saying the interfaces don't exist
            //bus.DeleteInterface(bus.GetInterface("org.alljoyn.Signals"));
            //bus.DeleteInterface(bus.GetInterface("org.alljoyn.Methods"));
            //bus.DeleteInterface(bus.GetInterface("org.alljoyn.Properties"));
            //bus.DeleteInterface(bus.GetInterface("org.alljoyn.Mixed"));
            //Assert.IsNull(bus.GetInterface("org.alljoyn.Signals"));
            //Assert.IsNull(bus.GetInterface("org.alljoyn.Methods"));
            //Assert.IsNull(bus.GetInterface("org.alljoyn.Properties"));
            //Assert.IsNull(bus.GetInterface("org.alljoyn.Mixed"));

            //InterfaceDescription[] nullIntfs = new InterfaceDescription[14];
            //bus.GetInterfaces(nullIntfs);
            //Assert.IsNull(nullIntfs[0]);
            //Assert.IsNull(nullIntfs[1]);
            //Assert.IsNull(nullIntfs[2]);
            //Assert.IsNull(nullIntfs[3]);
        }
Пример #4
0
        public void Start()
        {
            // Create the bus attachment
            bus = new BusAttachment("ServiceTest", true);
            bus.Start();
            Log.WriteLine("BusAttachment started");
            bus.Connect();
            Log.WriteLine("BusAttachment connect succeeded. BusName: " + bus.UniqueName);
            //Create interface
            string interfaceName = "org.test.a1234.AnnounceHandlerTest";
            string interfaceQcc  = "<node>" +
                                   $"<interface name='{interfaceName}'>" +
                                   "  <method name='Foo'>" +
                                   "  </method>" +
                                   "</interface>" +
                                   "</node>";

            bus.CreateInterfacesFromXml(interfaceQcc);
            //Test if the interface is there
            var iface  = bus.GetInterface(interfaceName);
            var secure = iface.IsSecure;
            var name   = iface.Name;
        }
Пример #5
0
        public void CreateInterfacesFromXMLTest()
        {
            BusAttachment bus = new BusAttachment("xmlinterfaces", true, 4);

            bus.CreateInterfacesFromXml(signalIntf);
            bus.CreateInterfacesFromXml(methodIntf);
            bus.CreateInterfacesFromXml(propertyIntf);
            bus.CreateInterfacesFromXml(mixedIntf);
            InterfaceDescription i = bus.GetInterface("org.alljoyn.Signals");
            Assert.IsNotNull(i);
            Assert.IsNotNull(bus.GetInterface("org.alljoyn.Methods"));
            Assert.IsNotNull(bus.GetInterface("org.alljoyn.Properties"));
            Assert.IsNotNull(bus.GetInterface("org.alljoyn.Mixed"));
            InterfaceDescription[] intfs = new InterfaceDescription[14];
            bus.GetInterfaces(intfs);
            Assert.IsNotNull(intfs[0]);
            Assert.IsNotNull(intfs[1]);
            Assert.IsNotNull(intfs[2]);
            Assert.IsNotNull(intfs[3]);

            // BUGBUG: DeleteInterface is throwing an exception saying the interfaces don't exist
            //bus.DeleteInterface(bus.GetInterface("org.alljoyn.Signals"));
            //bus.DeleteInterface(bus.GetInterface("org.alljoyn.Methods"));
            //bus.DeleteInterface(bus.GetInterface("org.alljoyn.Properties"));
            //bus.DeleteInterface(bus.GetInterface("org.alljoyn.Mixed"));
            //Assert.IsNull(bus.GetInterface("org.alljoyn.Signals"));
            //Assert.IsNull(bus.GetInterface("org.alljoyn.Methods"));
            //Assert.IsNull(bus.GetInterface("org.alljoyn.Properties"));
            //Assert.IsNull(bus.GetInterface("org.alljoyn.Mixed"));

            //InterfaceDescription[] nullIntfs = new InterfaceDescription[14];
            //bus.GetInterfaces(nullIntfs);
            //Assert.IsNull(nullIntfs[0]);
            //Assert.IsNull(nullIntfs[1]);
            //Assert.IsNull(nullIntfs[2]);
            //Assert.IsNull(nullIntfs[3]);
        }
Пример #6
0
        private async Task StartService()
        {
            serviceBus = new BusAttachment("About Service Example", true);
            serviceBus.Start();
            serviceBus.Connect();
            Log.WriteLine($"BusAttachment connect succeeded. BusName {serviceBus.UniqueName}");
            Session sessionOpts = new Session(TrafficType.Messages, false, Proximity.Any, Transport.Any);

            sessionPortListener = new SessionPortListener();
            sessionPortListener.AcceptSessionJoiner += SessionPortListener_AcceptSessionJoiner;
            sessionPortListener.SessionJoined       += SessionPortListener_SessionJoined;
            var sessionPort = ASSIGNED_SESSION_PORT;

            serviceBus.BindSessionPort(sessionPort, sessionOpts, sessionPortListener);

            var aboutData = new AboutData("en");

            byte[] appId = { 0x01, 0xB3, 0xBA, 0x14,
                             0x1E, 0x82, 0x11, 0xE4,
                             0x86, 0x51, 0xD1, 0x56,
                             0x1D, 0x5D, 0x46, 0xB0 };
            aboutData.AppId = appId;
            aboutData.SetDeviceName("My Device Name", "en");
            aboutData.DeviceId = "93c06771-c725-48c2-b1ff-6a2a59d445b8";
            aboutData.SetAppName("Application", "en");
            aboutData.SetManufacturer("Manufacturer2", "en");
            aboutData.ModelNumber = "123456";
            aboutData.SetDescription("A poetic description of this application", "en");
            aboutData.DateOfManufacture = "2014-03-24";
            aboutData.SoftwareVersion   = "0.1.2";
            aboutData.HardwareVersion   = "0.0.1";
            aboutData.SupportUrl        = "http://www.example.org";

            /*
             * The default language is automatically added to the `SupportedLanguages`
             * Users don't have to specify the AJSoftwareVersion its automatically added
             * to the AboutData/
             * Adding Spanish Localization values to the AboutData. All strings MUST be
             * UTF-8 encoded.
             */
            aboutData.SetDeviceName("Mi dispositivo Nombre", "es");
            aboutData.SetAppName("aplicación", "es");
            aboutData.SetManufacturer("fabricante", "es");
            aboutData.SetDescription("Una descripción poética de esta aplicación", "es");
            if (!aboutData.IsValid("en"))
            {
                Log.WriteLine("failed to setup about data.");
            }

            string xmlInterface = "<node>\n" +
                                  $"<interface name='{INTERFACE_NAME}'>\n" +
                                  "  <method name='Echo'>\n" +
                                  "    <arg name='out_arg' type='s' direction='in' />\n" +
                                  "    <arg name='return_arg' type='s' direction='out' />\n" +
                                  "  </method>\n" +
                                  "</interface>\n" +
                                  "</node>";

            Log.WriteLine(xmlInterface);
            serviceBus.CreateInterfacesFromXml(xmlInterface);
            busObject = create_my_alljoyn_busobject(serviceBus, "/example/path");
            serviceBus.RegisterBusObject(busObject);
            var aboutObj = new AboutObj(serviceBus, false);

            aboutObj.Announce(sessionPort, aboutData);
            Log.WriteLine("AboutObj Announce Succeeded.");
            Log.WriteLine("*********************************************************************************");
            Log.WriteLine("*********************************************************************************");

            while (!cancelSource.IsCancellationRequested)
            {
                await Task.Delay(10);
            }
        }