public async void GetRequest(String url, RequestCallback callback) { try { var response = await client.GetStringAsync(url); callback.Invoke(JsonConverter(response)); } catch (HttpRequestException) { callback.Invoke(null); } }
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; }
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); } }
private void OnTick(object sender, ElapsedEventArgs e) { RequestCallback?.Invoke(); }