public override IEnumerator RunJob() { Debug.Log("*************************** CoroutineJobConstruct ***************************"); SDKConstructRequest r = new SDKConstructRequest(); r.token = this.token; r.bank = this.bank; r.name = this.name; string jsonString = JsonUtility.ToJson(r); using (UnityWebRequest request = UnityWebRequest.Put(string.Format(Endpoint.URL_FORMAT, this.server, Endpoint.CONSTRUCT_MAP), jsonString)) { request.method = UnityWebRequest.kHttpVerbPOST; request.useHttpContinue = false; request.SetRequestHeader("Content-Type", "application/json"); request.SetRequestHeader("Accept", "application/json"); yield return(request.SendWebRequest()); Debug.Log("Response code: " + request.responseCode); if (request.isNetworkError || request.isHttpError) { Debug.LogError(request.error); } else if (request.responseCode == (long)HttpStatusCode.OK) { Debug.Log(request.downloadHandler.text); } } }
public override IEnumerator RunJob() { Debug.Log("*************************** CoroutineJobConstruct ***************************"); SDKConstructRequest r = new SDKConstructRequest(); r.token = host.token; r.bank = (host as Mapper).currentBank; r.name = this.name; string jsonString = JsonUtility.ToJson(r); using (UnityWebRequest request = UnityWebRequest.Put(string.Format(Endpoint.URL_FORMAT, host.server, Endpoint.CONSTRUCT_MAP), jsonString)) { request.method = UnityWebRequest.kHttpVerbPOST; request.useHttpContinue = false; request.SetRequestHeader("Content-Type", "application/json"); request.SetRequestHeader("Accept", "application/json"); yield return(request.SendWebRequest()); Debug.Log("Response code: " + request.responseCode); if (request.isNetworkError || request.isHttpError) { Debug.LogError(request.error); } else if (request.responseCode == (long)HttpStatusCode.OK) { SDKConstructResult result = JsonUtility.FromJson <SDKConstructResult>(request.downloadHandler.text); if (result.error == "none") { Debug.Log(string.Format("Started constructing a map width ID {0}, containing {1} images", result.id, result.size)); } } } }