QueueRequestError() private static method

Set the reqContainer into an error state, and queue it to invoke the ErrorCallback for that request
private static QueueRequestError ( CallRequestContainer reqContainer ) : void
reqContainer CallRequestContainer
return void
Ejemplo n.º 1
0
 private static void ProcessHttpResponse(CallRequestContainer reqContainer)
 {
     try
     {
         HttpWebResponse httpWebResponse = (HttpWebResponse)reqContainer.HttpRequest.GetResponse();
         if (httpWebResponse.StatusCode == HttpStatusCode.OK)
         {
             reqContainer.JsonResponse = PlayFabWebRequest.ResponseToString(httpWebResponse);
         }
         if (httpWebResponse.StatusCode != HttpStatusCode.OK || string.IsNullOrEmpty(reqContainer.JsonResponse))
         {
             reqContainer.JsonResponse = (reqContainer.JsonResponse ?? "No response from server");
             PlayFabWebRequest.QueueRequestError(reqContainer);
         }
         else
         {
             reqContainer.HttpState = HttpRequestState.Received;
         }
     }
     catch (Exception innerException)
     {
         string text = "Unhandled exception in ProcessHttpResponse : " + reqContainer.FullUrl;
         reqContainer.JsonResponse = (reqContainer.JsonResponse ?? text);
         Exception ex = new Exception(text, innerException);
         PlayFabWebRequest.QueueRequestError(reqContainer);
     }
 }
Ejemplo n.º 2
0
        private static void ProcessJsonResponse(CallRequestContainer reqContainer)
        {
            try
            {
                HttpResponseObject httpResponseObject = JsonWrapper.DeserializeObject <HttpResponseObject>(reqContainer.JsonResponse);
                if (httpResponseObject == null || httpResponseObject.code != 200)
                {
                    PlayFabWebRequest.QueueRequestError(reqContainer);
                }
                else
                {
                    reqContainer.JsonResponse = JsonWrapper.SerializeObject(httpResponseObject.data);
                    reqContainer.DeserializeResultJson();
                    reqContainer.ApiResult.Request    = reqContainer.ApiRequest;
                    reqContainer.ApiResult.CustomData = reqContainer.CustomData;
                    SingletonMonoBehaviour <PlayFabHttp> .instance.OnPlayFabApiResult(reqContainer.ApiResult);

                    object resultQueue = PlayFabWebRequest.ResultQueue;
                    lock (resultQueue)
                    {
                        PlayFabWebRequest.ResultQueue.Enqueue(delegate
                        {
                            PlayFabDeviceUtil.OnPlayFabLogin(reqContainer.ApiResult);
                        });
                    }
                    object resultQueue2 = PlayFabWebRequest.ResultQueue;
                    lock (resultQueue2)
                    {
                        PlayFabWebRequest.ResultQueue.Enqueue(delegate
                        {
                            try
                            {
                                PlayFabHttp.SendEvent(reqContainer.ApiEndpoint, reqContainer.ApiRequest, reqContainer.ApiResult, ApiProcessingEventType.Post);
                                reqContainer.InvokeSuccessCallback();
                            }
                            catch (Exception ex2)
                            {
                            }
                        });
                    }
                }
            }
            catch (Exception innerException)
            {
                string text = "Unhandled exception in ProcessJsonResponse : " + reqContainer.FullUrl;
                reqContainer.JsonResponse = (reqContainer.JsonResponse ?? text);
                Exception ex = new Exception(text, innerException);
                PlayFabWebRequest.QueueRequestError(reqContainer);
            }
        }
Ejemplo n.º 3
0
 private static void Post(CallRequestContainer reqContainer)
 {
     try
     {
         reqContainer.HttpRequest             = (HttpWebRequest)WebRequest.Create(reqContainer.FullUrl);
         reqContainer.HttpRequest.UserAgent   = "UnityEngine-Unity; Version: " + PlayFabWebRequest._unityVersion;
         reqContainer.HttpRequest.SendChunked = false;
         reqContainer.HttpRequest.Proxy       = null;
         foreach (KeyValuePair <string, string> keyValuePair in reqContainer.RequestHeaders)
         {
             reqContainer.HttpRequest.Headers.Add(keyValuePair.Key, keyValuePair.Value);
         }
         reqContainer.HttpRequest.ContentType = "application/json";
         reqContainer.HttpRequest.Method      = "POST";
         reqContainer.HttpRequest.KeepAlive   = PlayFabSettings.RequestKeepAlive;
         reqContainer.HttpRequest.Timeout     = PlayFabSettings.RequestTimeout;
         reqContainer.HttpRequest.AllowWriteStreamBuffering = false;
         reqContainer.HttpRequest.Proxy            = null;
         reqContainer.HttpRequest.ContentLength    = reqContainer.Payload.LongLength;
         reqContainer.HttpRequest.ReadWriteTimeout = PlayFabSettings.RequestTimeout;
         using (Stream requestStream = reqContainer.HttpRequest.GetRequestStream())
         {
             requestStream.Write(reqContainer.Payload, 0, reqContainer.Payload.Length);
         }
         reqContainer.HttpState = HttpRequestState.Sent;
     }
     catch (WebException ex)
     {
         reqContainer.JsonResponse = (PlayFabWebRequest.ResponseToString(ex.Response) ?? (ex.Status + ": WebException making http request to: " + reqContainer.FullUrl));
         WebException ex2 = new WebException(reqContainer.JsonResponse, ex);
         PlayFabWebRequest.QueueRequestError(reqContainer);
     }
     catch (Exception innerException)
     {
         reqContainer.JsonResponse = "Unhandled exception in Post : " + reqContainer.FullUrl;
         Exception ex3 = new Exception(reqContainer.JsonResponse, innerException);
         PlayFabWebRequest.QueueRequestError(reqContainer);
     }
 }