示例#1
0
    IEnumerator GetInstantValues(string url, InstantValuesListener listener)
    {
        while (true)
        {
            UnityWebRequest www = UnityWebRequest.Get(url);
            www.SetRequestHeader("Cookie", string.Format("device={0}", token));
            yield return(www.SendWebRequest());

            if (www.isNetworkError || www.isHttpError)
            {
                Debug.Log(www.error);
            }
            else
            {
                Debug.Log(www.downloadHandler.text);
                var values = JsonUtility.FromJson <SensorValue>(www.downloadHandler.text);
                listener.newValue(values);
            }

            yield return(new WaitForSeconds(10));
        }
    }
示例#2
0
 public void getInstantValues(InstantValuesListener listener)
 {
     behaviour.StartCoroutine(GetInstantValues("http://tfm.4m1g0.com:1880/status", listener));
 }