Ejemplo n.º 1
0
    // Initialize the ubiiClient, serviceClient and topicDataClient
    public async Task <Client> Initialize(Ubii.Clients.Client clientSpecs)
    {
        if (this.serviceConnectionMode == SERVICE_CONNECTION_MODE.ZEROMQ)
        {
            serviceClient = new NetMQServiceClient(host, portServiceZMQ);
        }
        else if (this.serviceConnectionMode == SERVICE_CONNECTION_MODE.HTTP)
        {
            string hostURL = host;
            if (!hostURL.StartsWith("http://"))
            {
                hostURL = "http://" + hostURL;
            }
            serviceClient = new UbiiServiceClientREST(hostURL, portServiceREST);
        }
        else if (this.serviceConnectionMode == SERVICE_CONNECTION_MODE.HTTPS)
        {
            string hostURL = host;
            if (!hostURL.StartsWith("https://"))
            {
                hostURL = "https://" + hostURL;
            }
            serviceClient = new UbiiServiceClientREST(hostURL, portServiceREST);
        }

        await InitServerSpec();

        //Debug.Log("ServerSpecs: " + serverSpecification);
        bool success = await InitClientRegistration(clientSpecs);

        InitTopicDataClient();

        return(clientSpecification);
    }
Ejemplo n.º 2
0
    public async Task Initialize()
    {
        clientNodeSpecification = new Ubii.Clients.Client
        {
            Name = clientName,
            IsDedicatedProcessingNode = isDedicatedProcessingNode
        };

        List <Ubii.Processing.ProcessingModule> pmDatabaseList = processingModuleDatabase.GetAllSpecifications();

        //Debug.Log("Node init PM list: " + pmDatabaseList.Count);
        foreach (Ubii.Processing.ProcessingModule pm in pmDatabaseList)
        {
            clientNodeSpecification.ProcessingModules.Add(pm);
        }

        bool success = await InitNetworkConnection();

        if (success)
        {
            OnConnected?.Invoke();

            processingModuleManager = new ProcessingModuleManager(this.GetID(), null, this.processingModuleDatabase, this.topicDataProxy);
            await SubscribeSessionInfo();

            OnInitialized?.Invoke();
            Debug.Log("Node client specs: " + clientNodeSpecification);
        }
        else
        {
            Debug.LogError("UbiiNode.Initialize() - failed to establish network connection to master node");
        }
    }
Ejemplo n.º 3
0
    // Initialize the ubiiClient, serviceClient and topicDataClient
    public async Task <Client> Initialize(Ubii.Clients.Client clientSpecs)
    {
        netmqServiceClient = new NetMQServiceClient(host, port);
        await InitServerSpec();

        //Debug.Log("ServerSpecs: " + serverSpecification);
        bool success = await InitClientRegistration(clientSpecs);

        InitTopicDataClient();

        return(clientSpecification);
    }
Ejemplo n.º 4
0
    private async void Initialize()
    {
        this.service_client = new UbiiServiceClientREST(this.host, this.service_port);

        // get server configuration
        ServiceRequest serverConfigRequest = new ServiceRequest {
            Topic = ubii.DEFAULT_TOPICS.SERVICES.SERVER_CONFIG
        };
        ServiceReply reply = await this.service_client.CallService(serverConfigRequest);

        if (reply.Server == null)
        {
            Debug.LogError("CallService(SERVER_CONFIG) failed");
            return;
        }
        server_config = reply.Server;
        Debug.Log("server_config: " + server_config);

        // register client
        ServiceRequest clientRegistrationRequest = new ServiceRequest {
            Topic  = ubii.DEFAULT_TOPICS.SERVICES.CLIENT_REGISTRATION,
            Client = new Ubii.Clients.Client {
                Name = client_name
            }
        };

        reply = await this.service_client.CallService(clientRegistrationRequest);

        if (reply.Client == null)
        {
            Debug.LogError("CallService(CLIENT_REGISTRATION) failed");
            return;
        }
        client_specification = reply.Client;
        Debug.Log("client_specification: " + client_specification);

        // setup topic data socket
        topicdata_client = new UbiiTopicDataClientWS(client_specification.Id, host, Int32.Parse(server_config.PortTopicDataWs));

        var test_topic = "/test/topic/unity";

        await Subscribe(test_topic, (TopicDataRecord record) =>
        {
            Debug.Log(record);
        });

        topicdata_client.SendTestTopicData(test_topic);
    }
Ejemplo n.º 5
0
    public async Task <bool> InitNetworkConnection()
    {
        networkClient           = new UbiiNetworkClient(masterNodeAddress, portServiceZMQ, portServiceREST, this.serviceConnectionMode, this.topicDataConnectionMode);
        clientNodeSpecification = await networkClient.Initialize(clientNodeSpecification);

        if (clientNodeSpecification == null)
        {
            return(false);
        }

        this.topicData      = new TopicDataBuffer();
        this.topicDataProxy = new TopicDataProxy(topicData, networkClient);
        networkClient.SetPublishDelay(publishDelay);

        return(true);
    }
Ejemplo n.º 6
0
    private async Task <bool> InitClientRegistration(Ubii.Clients.Client clientSpecs)
    {
        ServiceRequest clientRegistration = new ServiceRequest
        {
            Topic  = UbiiConstants.Instance.DEFAULT_TOPICS.SERVICES.CLIENT_REGISTRATION,
            Client = clientSpecs
        };
        //if(isDedicatedProcessingNode)
        //  TODO:  clientRegistration.Client.ProcessingModules = ...

        ServiceReply reply = await CallService(clientRegistration);

        if (reply.Client != null)
        {
            clientSpecification = reply.Client;
            return(true);
        }
        else if (reply.Error != null)
        {
            Debug.LogError("UbiiNetworkClient.InitClientRegistration() - " + reply);
        }

        return(false);
    }