IEnumerator ExecuteRequest(Dictionary <string, string> postData) { www.Send(); float elapsedTime = 0.0f; while (!www.isDone) { elapsedTime += Time.deltaTime; if (elapsedTime >= timeOutLimit) { CloudConnectorCore.ProcessResponse("TIME_OUT", elapsedTime); break; } yield return(null); } if (www.isError) { CloudConnectorCore.ProcessResponse(CloudConnectorCore.MSG_CONN_ERR + "Connection error after " + elapsedTime.ToString() + " seconds: " + www.error, elapsedTime); yield break; } CloudConnectorCore.ProcessResponse(www.downloadHandler.text, elapsedTime); }
public static void CreateRequest(Dictionary <string, string> form) { form.Add("ssid", spreadsheetId); form.Add("pass", servicePassword); EditorApplication.update += EditorUpdate; if (usePOST) { CloudConnectorCore.UpdateStatus("Establishing Connection at URL " + webServiceUrl); www = UnityWebRequest.Post(webServiceUrl, form); } else // Use GET. { string urlParams = "?"; foreach (KeyValuePair <string, string> item in form) { urlParams += item.Key + "=" + item.Value + "&"; } CloudConnectorCore.UpdateStatus("Establishing Connection at URL " + webServiceUrl + urlParams); www = UnityWebRequest.Get(webServiceUrl + urlParams); } startTime = EditorApplication.timeSinceStartup; www.Send(); }
static void EditorUpdate() { while (!www.isDone) { elapsedTime = EditorApplication.timeSinceStartup - startTime; if (elapsedTime >= timeOutLimit) { CloudConnectorCore.ProcessResponse("TIME_OUT", (float)elapsedTime); EditorApplication.update -= EditorUpdate; } return; } if (www.isError) { CloudConnectorCore.ProcessResponse(CloudConnectorCore.MSG_CONN_ERR + "Connection error after " + elapsedTime.ToString() + " seconds: " + www.error, (float)elapsedTime); return; } CloudConnectorCore.ProcessResponse(www.downloadHandler.text, (float)elapsedTime); EditorApplication.update -= EditorUpdate; }
public void CreateRequest(Dictionary <string, string> form) { form.Add("ssid", spreadsheetId); form.Add("pass", servicePassword); if (usePOST) { CloudConnectorCore.UpdateStatus("Establishing Connection at URL " + webServiceUrl); www = UnityWebRequest.Post(webServiceUrl, form); } // Use GET. else { string urlParams = "?"; foreach (KeyValuePair <string, string> item in form) { urlParams += item.Key + "=" + item.Value + "&"; } CloudConnectorCore.UpdateStatus("Establishing Connection at URL " + webServiceUrl + urlParams); www = UnityWebRequest.Get(webServiceUrl + urlParams); } StartCoroutine(ExecuteRequest(form)); }