コード例 #1
0
        public override void RequestAPI(RequestBase request)
        {
            var httpParam = new HttpParam();

            httpParam.url_    = kTestURL;
            httpParam.request = request;
            APINetworkManager.Instance.RequestAPI(this, httpParam);
        }
コード例 #2
0
        private IEnumerator RequestCoroutine(APIInterface apiInterface, HttpParam httpParam)
        {
            utility.log.DebugLog.TextAsset(apiInterface != null, "APIInterface is nul!!!");
            utility.log.DebugLog.TextAsset(httpParam != null, "HttpParam is null!!!");
            utility.log.DebugLog.TextAsset(!string.IsNullOrEmpty(httpParam.url_), "URL is invalid!!");

            UnityWebRequest www = new UnityWebRequest(httpParam.url_);

            www.method = UnityWebRequest.kHttpVerbPOST;
            var bytes = apiInterface.PackRequest(httpParam.request);

            Debug.Log(MessagePack.MessagePackSerializer.ToJson(bytes));
            UploadHandlerRaw handler = new UploadHandlerRaw(bytes);

            www.uploadHandler = handler;

            yield return(www.Send());

            if (www.isNetworkError)
            {
                utility.log.DebugLog.ErrorTextLog(www.error);
                if (httpParam.onError != null)
                {
                    httpParam.onError(404);
                }
            }
            else
            {
                httpParam.response = apiInterface.UnPackResponse(www.downloadHandler.data);

                if (httpParam.onDone != null)
                {
                    httpParam.onDone();
                }
            }
        }
コード例 #3
0
 public void Request(APIInterface apiInterface, HttpParam httpParam)
 {
     utility.log.DebugLog.TextAsset(monoBehaviour_ != null, "MonoBehaviour is nul!!!");
     monoBehaviour_.StartCoroutine(RequestCoroutine(apiInterface, httpParam));
 }
コード例 #4
0
        public void RequestAPI(APIInterface apiInterface, HttpParam httpParam)
        {
            var httpClient = new HttpClient(this);

            httpClient.Request(apiInterface, httpParam);
        }