private void SetData() { if (isDone) { if (string.IsNullOrEmpty(www.error) && error.IsNull()) { data = new JSONObject(www.text); CheckCode(data); } else { if (error.IsNull()) { error = new ErrorServerRequest(API_Code.ERROR_CODE, www.error); } } } else { if (error.IsNull()) { SetUnknownError(); } } }
protected void CheckCode(JSONObject data) { int code = API_Helper.GetCode(data); if (!API_Code.CodeIsNormalSuccess(code)) { string errorMessage = API_Helper.GetMessage(data); error = new ErrorServerRequest(code, errorMessage); } }
public virtual IEnumerator RequestData() { ValidateTimeOutRunner(); timeOutRunner.StartCountTimeOut(timeOut); var isNotConnectTheInternet = !IsNetworkConnected(); if (isNotConnectTheInternet) { timeOutRunner.StopCountTimeOut(); error = new ErrorServerRequest(API_Code.NO_INTERNET_CONNECTION_CODE); isDone = true; yield break; } }
protected IEnumerator WaitCheckTimeOut(Func <bool> isDone) { timeOutRunner.ResumeCountTimeOut(); while (!timeOutRunner.isTimeOut && !isDone()) { yield return(null); } if (timeOutRunner.isTimeOut) { error = new ErrorServerRequest(API_Code.TIME_OUT_CODE); } timeOutRunner.StopCountTimeOut(); }
protected void SetUnknownError() { error = new ErrorServerRequest(API_Code.ERROR_CODE); isDone = true; }