Esempio n. 1
0
    void Update()
    {
        if (androidDevice)
        {
            string serverUptimeNew = BufferServicesControllerInterface.getBufferUptime();

            if (serverUptimeNew != serverUptime)
            {
                serverUptime = serverUptimeNew;
                GameObject.Find("UptimeText").GetComponent <Text>().text = serverUptime;
            }

            if (updateClientInfo)
            {
                foreach (int id in clientIDsToUpdateInfo)
                {
                    GameObject infoPanel     = GameObject.FindWithTag("clientID " + id.ToString());
                    int        samplesPut    = BufferServicesControllerInterface.getClientSamplesPut(id);
                    int        samplesGotten = BufferServicesControllerInterface.getClientSamplesGotten(id);
                    int        eventsPut     = BufferServicesControllerInterface.getClientEventsPut(id);
                    int        eventsGotten  = BufferServicesControllerInterface.getClientEventsGotten(id);
                    infoPanel.transform.Find("ClientSamplesPutText").GetComponent <Text>().text    = "Samples Put: " + samplesPut.ToString();
                    infoPanel.transform.Find("ClientSamplesGottenText").GetComponent <Text>().text = "Samples Gotten: " + samplesGotten.ToString();
                    infoPanel.transform.Find("ClientEventsPutText").GetComponent <Text>().text     = "Events Put: " + eventsPut.ToString();
                    infoPanel.transform.Find("ClientEventsGottenText").GetComponent <Text>().text  = "Events Gotten: " + eventsGotten.ToString();

                    int    threadID = threadIDsToClientIDs.FirstOrDefault(x => x.Value == id).Key;
                    string status   = BufferServicesControllerInterface.getThreadStatus(threadID);
                    infoPanel.transform.Find("ThreadStatusText").GetComponent <Text>().text = "Status: " + status;
                }
            }
        }
    }
Esempio n. 2
0
    public IEnumerator stopFilePlaybackCLientAndServer()
    {
        BufferServicesControllerInterface.stopThread(threadID);
        yield return(new WaitForSeconds(0.5f));

        //Stop Clients
        Debug.Log("Stopped Clients = " + BufferServicesControllerInterface.stopClients());

        //Stop Server
        Debug.Log("Stopped Server = " + BufferServicesControllerInterface.stopServer());
    }
Esempio n. 3
0
 private void stopThread(int threadID, GameObject button)
 {
     if (androidDevice)
     {
         BufferServicesControllerInterface.stopThread(threadID);
         updateClientInfo = false;
         int clientID = Convert.ToInt32(button.transform.Find("ClientInfoPanel(Clone)").tag.Split(' ')[1]);
         clientIDsToUpdateInfo.Remove(clientID);
     }
     GameObject.Destroy(button.transform.Find("ClientInfoPanel(Clone)").gameObject);
 }
Esempio n. 4
0
 public void startServer()
 {
     if (serverSwitch.GetComponent <Toggle>().isOn)
     {
         if (androidDevice)
         {
             serverServiceName = BufferServicesControllerInterface.startServer();
             GameObject.Find("ServerNotifications").GetComponent <Text>().text = serverServiceName;
         }
         GameObject.Find("ServerButtonText").GetComponent <Text>().text = "Stop Server";
     }
 }
Esempio n. 5
0
    void Start()
    {
                #if UNITY_ANDROID && !UNITY_EDITOR
        BufferServicesControllerInterface.Initialize();
        androidDevice = true;
                #endif

        serverSwitch  = GameObject.Find("ToggleServerStart");
        clientsSwitch = GameObject.Find("ToggleClientsStart");

        clientIDsToUpdateInfo = new List <int>();
    }
Esempio n. 6
0
 public void startClients()
 {
     if (clientsSwitch.GetComponent <Toggle>().isOn)
     {
         if (androidDevice)
         {
             clientsServiceName = BufferServicesControllerInterface.startClients();
             GameObject.Find("ClientsNotifications").GetComponent <Text>().text = clientsServiceName;
         }
         GameObject.Find("ClientsButtonText").GetComponent <Text>().text = "Stop Clients";
         StartCoroutine(getAllThreads());
     }
 }
Esempio n. 7
0
 public void stopClients()
 {
     if (!clientsSwitch.GetComponent <Toggle>().isOn)
     {
         if (androidDevice)
         {
             if (BufferServicesControllerInterface.stopClients())
             {
                 clientsServiceName = "None";
             }
             GameObject.Find("ClientsNotifications").GetComponent <Text>().text = clientsServiceName;
         }
         GameObject.Find("ClientsButtonText").GetComponent <Text>().text = "Start Clients";
         clearThreadsDropDownPanel();
     }
 }
Esempio n. 8
0
    public IEnumerator getAllThreads()
    {
        threads = new Dictionary <int, string>();
        threadIDsToClientIDs = new Dictionary <int, int>();
        yield return(new WaitForSeconds(1));

        if (androidDevice)
        {
            string[] result = BufferServicesControllerInterface.getAllThreadsNamesAndIDs();
            for (int i = 0; i < result.Length; ++i)
            {
                threads.Add(int.Parse(result[i].Split(':')[0]), result[i].Split(':')[1]);
            }
        }
        else
        {
            threads.Add(0, "Hello");
            threads.Add(1, "You");
        }
        generateThreadsDropDownPanel();
    }
Esempio n. 9
0
    public IEnumerator startServerAndAllClients()
    {
        if (androidDevice)
        {
            //Start Server
            Debug.Log("Started: " + BufferServicesControllerInterface.startServer());

            yield return(new WaitForSeconds(10));           //These waits are for the Services to have time to pass around their intents

            //Start Clients
            Debug.Log("Started: " + BufferServicesControllerInterface.startClients());

            yield return(new WaitForSeconds(1));

            //Start FilePlayback client
            string[] result = BufferServicesControllerInterface.getAllThreadsNamesAndIDs();
            while (result.Length == 0)          //Wait until the ClientsService updates the controller with all the available threads
            {
                yield return(new WaitForSeconds(1));

                result = BufferServicesControllerInterface.getAllThreadsNamesAndIDs();
            }
            for (int i = 0; i < result.Length; ++i)
            {
                if (result[i].Split(':')[1] == "File Playback")
                {
                    Debug.Log("Starting FilePlayback");
                    threadID = int.Parse(result[i].Split(':')[0]);
                    BufferServicesControllerInterface.startThread(threadID);
                }
            }
            yield return(new WaitForSeconds(1));

            //Start the internal buffer client
            GameObject.Find("Sphere").GetComponent <MovingWithAlphaLatEvents>().initializeBuffer();
        }
    }
Esempio n. 10
0
    private IEnumerator startThread(int threadID, GameObject button)
    {
        if (androidDevice)
        {
            //Get the clientIDs of all the clients running before we start a new one
            List <int> oldRunningClientIDs = new List <int>();
            int[]      result = BufferServicesControllerInterface.getClientIDs();
            for (int i = 0; i < result.Length; ++i)
            {
                oldRunningClientIDs.Add(result[i]);
            }
            if (verbose)
            {
                Debug.Log("size of old clients list = " + oldRunningClientIDs.Count);
            }

            //Start a new thread (client)
            BufferServicesControllerInterface.startThread(threadID);
            if (verbose)
            {
                Debug.Log("Starting thread: " + threadID.ToString());
            }
            yield return(new WaitForSeconds(1f));


            //Get the new client ID by comparing the old returned list of ids with the new one
            List <int> newRunningClientIDs = new List <int>();
            result = BufferServicesControllerInterface.getClientIDs();
            for (int i = 0; i < result.Length; ++i)
            {
                newRunningClientIDs.Add(result[i]);
            }
            if (verbose)
            {
                Debug.Log("size of new clients list = " + newRunningClientIDs.Count);
            }

            //Client IDs get created but do not get deleted so connect a new client ID to a thread ID or call a preexisting client ID by the button's thread ID
            int clientID = -1;
            IEnumerable <int> newClientID = new List <int>();
            newClientID = (from s in newRunningClientIDs where !oldRunningClientIDs.Contains(s) select s);
            if (newClientID.Count() > 0)
            {
                clientID = newClientID.ElementAt(0);
                threadIDsToClientIDs.Add(threadID, clientID);
            }
            else
            {
                clientID = threadIDsToClientIDs[threadID];
            }

            //Make the info panel
            GameObject clientInfo = (GameObject)Instantiate(clientInfoPanel);
            clientInfo.transform.SetParent(button.transform);
            clientInfo.tag = "clientID " + clientID.ToString();
            RectTransform clientInfoTransform = clientInfo.GetComponent <RectTransform>();
            clientInfoTransform.anchoredPosition = new Vector3(0, 0, 0);
            clientInfo.transform.Find("ClientIDText").GetComponent <Text>().text = "Client ID: " + clientID.ToString();

            updateClientInfo = true;
            clientIDsToUpdateInfo.Add(clientID);
        }
    }