Пример #1
0
            public IEnumerator ProcessRequest()
            {
                Logger.Instance.Log("DETAIL", "Process Request: " + _status);

                /*if (_request.Uri.ToString().Contains("characterChoice") || _request.Uri.ToString().Contains("placeTokenOnTile"))
                 * {
                 *  Logger.Instance.Log("LOG", "URI: " + _request.Uri.ToString());
                 *  OnHeaderEnumerationDelegate callback = (header, values) => {
                 *      string log = header + ":\n";
                 *      foreach (string value in values)
                 *          log += "* " + value + "\n";
                 *      Logger.Instance.Log("LOG", log);
                 *  };
                 *  _request.EnumerateHeaders(callback);
                 * }*/

                _request = _request.Send();

                while (_request.State < HTTPRequestStates.Finished)
                {
                    yield return(new WaitForSeconds(0.1f));

                    _status += ".";
                }

                bool success = CheckRequestStatus();

                if (success)
                {
                    _result = new JSONObject(_request.Response.DataAsText);
                    if (JSONTools.HasFieldOfTypeNumber(_result, "status") && _result.GetField("status").n == 0)
                    {
                        string encoded = _result.GetField("error").str;
                        string decoded = AsciiDecoder.Decode(encoded);

                        Logger.Instance.Log("NW_WARNING", decoded);
                        _success = false;
                    }
                    else
                    {
                        Logger.Instance.Log("NW_INFO", "Success");
                        _success = true;
                    }
                }
                else
                {
                    Logger.Instance.Log("NW_WARNING", _status);
                    _success = false;
                }

                _done = true;

                _callback(this);
            }