/// <summary> /// Abort the request manually /// </summary> public void Abort() { if (!this.IsAborted && this.Request != null) { try { this.IsAborted = true; if (!this.Request.isDone) { this.Request.Abort(); } } catch (Exception error) { HttpBase.DebugLog(this.EnableDebug, error.Message, true); } finally { this.Request = null; } } }
/// <summary> /// Load data from the server using a HTTP GET request /// </summary> /// <param name="options">An options object.</param> /// <param name="callback">A callback function that is executed when the request is finished.</param> /// <typeparam name="T">The relement type of the response.</typeparam> public static void Get <T>(RequestHelper options, Action <Exception, ResponseHelper, T> callback) { StaticCoroutine.StartCoroutine(HttpBase.DefaultUnityWebRequest <T>(options, null, UnityWebRequest.kHttpVerbGET, callback)); }
/// <summary> /// Load data from the server using a HTTP PUT request. /// </summary> /// <param name="options">An options object.</param> /// <param name="bodyJson">A plain object that is sent to the server with the request.</param> /// <param name="callback">A callback function that is executed when the request is finished.</param> /// <typeparam name="T">The element type of the response.</typeparam> public static void Put <T>(RequestHelper options, object bodyJson, Action <Exception, ResponseHelper, T> callback) { StaticCoroutine.StartCoroutine(HttpBase.DefaultUnityWebRequest <T>(options, bodyJson, UnityWebRequest.kHttpVerbPUT, callback)); }
/// <summary> /// Create an HTTP request with the specified options and callback. /// </summary> /// <param name="options">The options of the request.</param> /// <param name="callback">A callback function that is executed when the request is finished.</param> /// <typeparam name="T">The element type of the response.</typeparam> public static void Request <T>(RequestHelper options, Action <RequestException, ResponseHelper, T> callback) { StaticCoroutine.StartCoroutine(HttpBase.DefaultUnityWebRequest <T>(options, callback)); }
/// <summary> /// Load a JSON array from the server using a HTTP GET request /// </summary> /// <param name="options">The options of the request.</param> /// <param name="callback">A callback function that is executed when the request is finished.</param> /// <typeparam name="T">The element type of the array.</typeparam> public static void GetArray <T>(RequestHelper options, Action <RequestException, ResponseHelper, T[]> callback) { options.Method = UnityWebRequest.kHttpVerbGET; StaticCoroutine.StartCoroutine(HttpBase.DefaultUnityWebRequest <T>(options, callback)); }