public void ProcessResponse(KSProjectResponse response) { if (!string.IsNullOrEmpty(response.meta.next)) // && response.meta.offset < 10001) { string url = "http://127.0.0.1:8000" + response.meta.next; KSJSON.me.getURL(gameObject, "ProcessResponse", url); } if (projectQueue.Count > 0) { //projectQueue.AddRange(response.objects); foreach (KSProject proj in response.objects) { projectQueue.Enqueue(proj); } } else { //projectQueue.AddRange(response.objects); foreach (KSProject proj in response.objects) { projectQueue.Enqueue(proj); } StartCoroutine(BuildProjects()); } //Debug.Log("Queue Size: " + projectQueue.Count); }
public void getOffline(GameObject caller, string message, string resource) { TextAsset text = (TextAsset)Resources.Load(resource); //Debug.Log(text.text); KSProjectResponse response = JsonReader.Deserialize <KSProjectResponse>(text.text); caller.SendMessage(message, response); }
IEnumerator APIWWW(GameObject caller, string message, string url) { WWW www = new WWW(url); yield return(www); //Debug.Log(www.error + ": " + url); //float start = Time.realtimeSinceStartup; KSProjectResponse response = JsonReader.Deserialize <KSProjectResponse>(www.text); //Debug.Log("Processed JSON in " + ((Time.realtimeSinceStartup - start) * 1000).ToString() + " msec."); caller.SendMessage(message, response); }
IEnumerator wwwProjects(GameObject caller, string[] queries) { string url = apiURL + string.Join("&", queries); WWW www = new WWW(url); yield return(www); //Debug.Log(www.error + ": " + url); float start = Time.realtimeSinceStartup; KSProjectResponse response = JsonReader.Deserialize <KSProjectResponse>(www.text); Debug.Log("Processed JSON in " + (Time.time - (start * 1000)).ToString() + " msec."); caller.SendMessage("setProjects", response.objects); }
IEnumerator streamCSVtoProjects(GameObject caller, string[] lines) { int i = 0; int chunk = 1000; KSProject[] projects = new KSProject[chunk]; KSProjectResponse response = new KSProjectResponse(); response.meta = new KSMeta(); while(i < lines.Length) { for(int j = 0; j < chunk && i < lines.Length; j++) { projects[j] = parseProjectLine(lines[i]); i++; } response.objects = projects; caller.GetComponent<City>().ProcessResponse(response); yield return null; } }
IEnumerator streamCSVtoProjects(GameObject caller, string[] lines) { int i = 0; int chunk = 1000; KSProject[] projects = new KSProject[chunk]; KSProjectResponse response = new KSProjectResponse(); response.meta = new KSMeta(); while (i < lines.Length) { for (int j = 0; j < chunk && i < lines.Length; j++) { projects[j] = parseProjectLine(lines[i]); i++; } response.objects = projects; caller.GetComponent <City>().ProcessResponse(response); yield return(null); } }
public void ProcessResponse(KSProjectResponse response) { if(!string.IsNullOrEmpty(response.meta.next))// && response.meta.offset < 10001) { string url = "http://127.0.0.1:8000" + response.meta.next; KSJSON.me.getURL(gameObject, "ProcessResponse", url); } if(projectQueue.Count > 0) { //projectQueue.AddRange(response.objects); foreach(KSProject proj in response.objects) projectQueue.Enqueue(proj); } else { //projectQueue.AddRange(response.objects); foreach(KSProject proj in response.objects) projectQueue.Enqueue(proj); StartCoroutine(BuildProjects()); } //Debug.Log("Queue Size: " + projectQueue.Count); }