示例#1
0
        public async void GetRequest(String url, RequestCallback callback)
        {
            try
            {
                var response = await client.GetStringAsync(url);

                callback.Invoke(JsonConverter(response));
            }
            catch (HttpRequestException)
            {
                callback.Invoke(null);
            }
        }
示例#2
0
        private IEnumerator GetData()
        {
            UnityWebRequest www = UnityWebRequest.Get(requestURL);

            yield return(www.SendWebRequest());

            bool success = false;

            if (www.isNetworkError || www.isHttpError)
            {
                if (JCS_GameSettings.instance.DEBUG_MODE)
                {
                    JCS_Debug.LogWarning(www.error);
                }
            }
            else
            {
                mResultData = www.downloadHandler.data;
                WriteFileAsCache(requestPath, mResultData);

                success = true;
            }

            if (requestCallback != null)
            {
                requestCallback.Invoke(requestPath, success);
            }
            requestCallback = null;

            downloadList.Remove(requestPath);
            requesting = false;
        }
示例#3
0
        public async void PostRequest(String url, Dictionary <string, string> arguments, RequestCallback callback)
        {
            try
            {
                var content  = new FormUrlEncodedContent(arguments);
                var response = await client.PostAsync(url, content);

                var responseStr = await response.Content.ReadAsStringAsync();

                callback.Invoke(JsonConverter(responseStr));
            }
            catch (HttpRequestException)
            {
                callback.Invoke(null);
            }
        }
示例#4
0
 private void OnTick(object sender, ElapsedEventArgs e)
 {
     RequestCallback?.Invoke();
 }