public void onFailure() { GuLog.Info("NativeOkHttpMethodWrapperCallBack: onFailure"); if (mNativeOnFailure != null) { mNativeOnFailure(ResponseErroInfo.GetErrorInfo(-1, "http io error")); } }
public void handleAuthenticatioError(HTTPRequest originalRequest, Action <ResponseErroInfo> errCallBack) { mAuthenticationUtils.reNewToken((scuccessrResultBack) => { string token = scuccessrResultBack.info; reSendRequest(originalRequest, token); }, (errResultBack) => { errCallBack(ResponseErroInfo.GetErrorInfo(401, "renew token is error")); }); }
private void sendRetryRequest(int oddRetryCount, Action <ResponseErroInfo> errCallBack, HTTPRequest originalRequest, string info) { if (oddRetryCount <= 0) { errCallBack(ResponseErroInfo.GetErrorInfo(LocalRequestStatusCode.TimedOut, info)); Debug.Log("sendRetryRequest send request is over"); } else { retrySendRequest(originalRequest, oddRetryCount); } }
public void handleRetryRequest(HTTPResponse response, HTTPRequest originalRequest, Action <ResponseErroInfo> errCallBack) { int oddRetryCount = getOddRetryCount(originalRequest); Debug.Log("<><>retryCount<><>" + oddRetryCount); if (oddRetryCount > 0) { retrySendRequest(originalRequest, oddRetryCount); } else { Debug.Log("handleRetryRequest send request is over"); errCallBack(ResponseErroInfo.GetErrorInfo(response.StatusCode, response.DataAsText)); } }
public void handleResqAndResp(HTTPRequest originalRequest, HTTPResponse response, Action <string> callBack, Action <ResponseErroInfo> errCallBack) { Debug.Log("<><>handleResqAndResp<><>" + originalRequest.State); int oddRetryCount = getOddRetryCount(originalRequest); switch (originalRequest.State) { case HTTPRequestStates.Finished: string requestInfo = "Response url:" + originalRequest.Uri.AbsolutePath + " body:" + response.DataAsText; GuLog.Info(requestInfo); if (response.IsSuccess) { callBack(response.DataAsText); } else { handleResponseError(originalRequest, response, errCallBack); } break; case HTTPRequestStates.Aborted: errCallBack(ResponseErroInfo.GetErrorInfo(LocalRequestStatusCode.Aborted, "Request Aborted")); break; case HTTPRequestStates.Initial: errCallBack(ResponseErroInfo.GetErrorInfo(LocalRequestStatusCode.Initial, "Request Initial")); break; case HTTPRequestStates.Processing: errCallBack(ResponseErroInfo.GetErrorInfo(LocalRequestStatusCode.Processing, "Request Processing")); break; case HTTPRequestStates.Queued: errCallBack(ResponseErroInfo.GetErrorInfo(LocalRequestStatusCode.Queued, "Request Queued")); break; case HTTPRequestStates.Error: sendRetryRequest(oddRetryCount, errCallBack, originalRequest, "Error"); break; case HTTPRequestStates.ConnectionTimedOut: case HTTPRequestStates.TimedOut: sendRetryRequest(oddRetryCount, errCallBack, originalRequest, "TimedOut"); break; } }
public void onResponse(string result) { GuLog.Info("NativeOkHttpMethodWrapperCallBack: onResponse: " + result); NativeResponseData responseData = JsonConvert.DeserializeObject <NativeResponseData>(result); if (responseData.isSuccess == 1) { if (mNativeOnResponse != null) { mNativeOnResponse(responseData.body); } } else { if (mNativeOnFailure != null) { mNativeOnFailure(ResponseErroInfo.GetErrorInfo(responseData.code, responseData.body)); } } }
public void handleResponseError(HTTPRequest originalRequest, HTTPResponse response, Action <ResponseErroInfo> errCallBack) { if (response.StatusCode == 401) { handleAuthenticatioError(originalRequest, errCallBack); } else if (response.StatusCode == 503) { handleRetryRequest(response, originalRequest, errCallBack); } else { Debug.Log("response.DataAsText:" + response.DataAsText + " url:" + originalRequest.CurrentUri.ToString()); if (isResetError(originalRequest, response)) { Debug.Log("notify reset"); mClearLocalDataSignal.Dispatch(); } errCallBack(ResponseErroInfo.GetErrorInfo(response.StatusCode, response.DataAsText)); } }