async private void RunTestSubscribePublish()
    {
        await ubiiClient.WaitForConnection();

        string topic   = "/" + ubiiClient.GetID() + "/unity3D_client/test/subcribe_publish_simple";
        bool   success = false;

        Action <TopicDataRecord> callback = (TopicDataRecord record) =>
        {
            success = record.Bool;
        };

        await ubiiClient.Subscribe(topic, callback);

        ubiiClient.Publish(new Ubii.TopicData.TopicData {
            TopicDataRecord = new Ubii.TopicData.TopicDataRecord {
                Topic = topic, Bool = true
            }
        });

        await Task.Delay(1000).ContinueWith(async(Task t) =>
        {
            await ubiiClient.Unsubscribe(topic, callback);

            if (success)
            {
                Debug.Log("RunTestSubscribePublish SUCCESS!");
            }
            else
            {
                Debug.LogError("RunTestSubscribePublish FAILURE!");
            }
        });
    }
    private void CreateUbiiSpecs()
    {
        topicTestPublishSubscribe = "/" + ubiiClient.GetID() + "/test_publish_subscribe/object_movement";

        ubiiDevice = new Ubii.Devices.Device {
            Name = deviceName, ClientId = ubiiClient.GetID(), DeviceType = Ubii.Devices.Device.Types.DeviceType.Participant
        };
        ubiiDevice.Components.Add(new Ubii.Devices.Component {
            IoType = Ubii.Devices.Component.Types.IOType.Publisher, MessageFormat = "ubii.dataStructure.Vector3", Topic = topicTestPublishSubscribe
        });
    }
Пример #3
0
    private void CreateSpecs()
    {
        this.inputTopic  = "/" + ubiiClient.GetID() + "/test-sessions/input/vec3";
        this.outputTopic = "/" + ubiiClient.GetID() + "/test-sessions/output/vec3";

        this.pmSpecs = new Ubii.Processing.ProcessingModule
        {
            Name = "Unity3D-Client-TestSessions-PM-01",
            OnProcessingStringified = "(inputs, outputs, state) => { outputs.outVec3 = inputs.inVec3; }",
            ProcessingMode          = new Ubii.Processing.ProcessingMode {
                Frequency = new Ubii.Processing.ProcessingMode.Types.Frequency {
                    Hertz = 10
                }
            }
        };
        this.pmSpecs.Inputs.Add(new Ubii.Processing.ModuleIO {
            InternalName = "inVec3", MessageFormat = "ubii.dataStructure.Vector3"
        });
        this.pmSpecs.Outputs.Add(new Ubii.Processing.ModuleIO {
            InternalName = "outVec3", MessageFormat = "ubii.dataStructure.Vector3"
        });
        this.pmSpecs.Authors.Add("Sandro Weber");

        this.sessionSpecs = new Ubii.Sessions.Session
        {
            Name = "Unity3D-Client-TestSessions-Session-01"
        };
        this.sessionSpecs.Authors.Add("Sandro Weber");
        this.sessionSpecs.ProcessingModules.Add(this.pmSpecs);
        Ubii.Sessions.IOMapping ioMapping = new Ubii.Sessions.IOMapping
        {
            ProcessingModuleName = this.pmSpecs.Name
        };
        ioMapping.InputMappings.Add(new Ubii.Sessions.TopicInputMapping {
            InputName = "inVec3", Topic = this.inputTopic
        });
        ioMapping.OutputMappings.Add(new Ubii.Sessions.TopicOutputMapping {
            OutputName = "outVec3", Topic = this.outputTopic
        });
        this.sessionSpecs.IoMappings.Add(ioMapping);
    }