Ejemplo n.º 1
0
        public HTTPRequest Request(HTTPMethods method, string path, OnAppRespondedDelegate callback, OnAppRespondedDelegate err)
        {
            return(new HTTPRequest(
                       new System.Uri(URI, path),
                       method,
                       (HTTPRequest request_, HTTPResponse response_) =>
            {
                if (request_.State != HTTPRequestStates.Finished)
                {
                    request_ = null;
                    Debug.Log("Request " + path + " returned null");
                    return;
                }

                var json = JSON.Parse(request_.Response.DataAsText);
                if (json != null && json["error"] == json["null"])
                {
                    try
                    {
                        callback(json);
                    }
                    catch
                    {
                        Debug.Log("Network request callback threw: " + method.ToString() + ":" + path);
                    }
                }
                else
                {
                    err(json);
                }
            }));
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Tries to find the appropriate HTTPMethod for the given HTTPMethods.
 /// </summary>
 /// <param name="myCode">A HTTPMethod code as string</param>
 /// <returns>A HTTPMethod</returns>
 public static HTTPMethod ParseEnum(HTTPMethods myHTTPMethodsEnum)
 {
     return((from _FieldInfo in typeof(HTTPMethod).GetFields()
             let __HTTPMethod = _FieldInfo.GetValue(null) as HTTPMethod
                                where  __HTTPMethod != null
                                where  __HTTPMethod.MethodName == myHTTPMethodsEnum.ToString()
                                select __HTTPMethod).FirstOrDefault());
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Tries to find the appropriate HTTPMethod for the given HTTPMethods.
        /// </summary>
        /// <param name="HTTPMethodEnum">A HTTP method.</param>
        /// <param name="HTTPMethod">The parsed HTTP method.</param>
        /// <returns>true or false</returns>
        public static Boolean TryParseEnum(HTTPMethods HTTPMethodEnum, out HTTPMethod HTTPMethod)
        {
            HTTPMethod = (from _FieldInfo in typeof(HTTPMethod).GetFields()
                          let __HTTPMethod = _FieldInfo.GetValue(null) as HTTPMethod
                                             where  __HTTPMethod != null
                                             where  __HTTPMethod.MethodName == HTTPMethodEnum.ToString()
                                             select __HTTPMethod).FirstOrDefault();

            return((HTTPMethod != null) ? true : false);
        }