private void OnServerRequestComplete(AsyncJSONRequest serverRequest)
    {
        Status = eRequestStatus.completed;

        if (serverRequest.GetRequestState() == AsyncJSONRequest.eRequestState.succeded)
        {
            ServerResponse = serverRequest.GetResult();

            string responseResult = JsonUtilities.ParseString(ServerResponse, "result");

            if (responseResult == "Success")
            {
                ResultCode    = eResult.success;
                ResultDetails = "";
            }
            else
            {
                // Successfully got response back, but server said no.
                ResultCode    = eResult.failed_server_denied;
                ResultDetails = "Server Response: " + responseResult;
            }
        }
        else
        {
            // Failed to get a response from the server
            ResultCode    = eResult.failed_server_connection;
            ResultDetails = "Connection Failure: " + serverRequest.GetFailureReason();
        }

        // Notify the caller that the request is completed
        m_onCompleteCallback(this);
        m_onCompleteCallback = null;
    }
예제 #2
0
    private static IEnumerator GetFromURL(string url, OnRequestCompleteDelegate callback)
    {
        url = url.Replace(" ", "%20");
        WWW www = new WWW(url);

        do
        {
            yield return(IEnumeratorExtensions.AvoidRunThru);
        } while (!www.isDone);

        if (!string.IsNullOrEmpty(www.error))
        {
            Debug.LogError(www.error);
            yield break;
        }
        else
        {
            if (www.text.Contains("404 Not Found"))
            {
                Debug.LogError(www.text);
            }
            else
            {
                callback(www.bytes);
            }
        }
    }
    public void Execute(OnRequestCompleteDelegate onComplete)
    {
        if (Status != eRequestStatus.pending_path_find || Status != eRequestStatus.pending_server_response)
        {
            Status = eRequestStatus.pending_path_find;
            m_onCompleteCallback = onComplete;

            PathfindingSystem.AddPathRequest(m_entity.CurrentRoomKey, m_entity.Position, TargetPosition, this.OnPathComputed);
        }
    }
    public void Execute(OnRequestCompleteDelegate onComplete)
    {
        if (Status != eRequestStatus.pending_path_find || Status != eRequestStatus.pending_server_response)
        {
            m_onCompleteCallback = onComplete;

            if (Point3d.DistanceSquared(OriginalPosition, OriginPortalEntryPoint) > WITHIN_PORTAL_TOLERANCE_SQUARED)
            {
                Status = eRequestStatus.pending_path_find;

                PathfindingSystem.AddPathRequest(
                    m_entity.CurrentRoomKey,
                    m_entity.Position,
                    OriginPortalEntryPoint,
                    this.OnPathComputed);
            }
            else
            {
                Status = eRequestStatus.pending_server_response;
            }
        }
    }
    private void OnServerRequestComplete(AsyncJSONRequest serverRequest)
    {
        Status = eRequestStatus.completed;

        if (serverRequest.GetRequestState() == AsyncJSONRequest.eRequestState.succeded)
        {
            ServerResponse = serverRequest.GetResult();

            string responseResult = JsonUtilities.ParseString(ServerResponse, "result");

            if (responseResult == "Success")
            {
                ResultCode = eResult.success;
                ResultDetails = "";
            }
            else
            {
                // Successfully got response back, but server said no.
                ResultCode = eResult.failed_server_denied;
                ResultDetails = "Server Response: " + responseResult;
            }
        }
        else
        {
            // Failed to get a response from the server
            ResultCode = eResult.failed_server_connection;
            ResultDetails = "Connection Failure: "+serverRequest.GetFailureReason();
        }

        // Notify the caller that the request is completed
        m_onCompleteCallback(this);
        m_onCompleteCallback = null;
    }
    public void Execute(OnRequestCompleteDelegate onComplete)
    {
        if (Status != eRequestStatus.pending_path_find || Status != eRequestStatus.pending_server_response)
        {
            m_onCompleteCallback = onComplete;

            if (Point3d.DistanceSquared(OriginalPosition, OriginPortalEntryPoint) > WITHIN_PORTAL_TOLERANCE_SQUARED)
            {
                Status = eRequestStatus.pending_path_find;

                PathfindingSystem.AddPathRequest(
                    m_entity.CurrentRoomKey,
                    m_entity.Position,
                    OriginPortalEntryPoint,
                    this.OnPathComputed);
            }
            else
            {
                Status = eRequestStatus.pending_server_response;
            }
        }
    }
        /// <summary>
        /// See <see cref="IUrlRequestClient.OnRequestComplete"/> for details.
        /// </summary>
        /// <param name="action">Action to be executed when <see cref="IUrlRequestClient.OnRequestComplete(IUrlRequest)"/>
        /// is called</param>
        /// <returns>
        /// Fluent Builder, call <see cref="UrlRequestClientBuilder.Build"/> to create
        /// a new <see cref="IUrlRequestClient"/> instance
        /// </returns>
        public UrlRequestClientBuilder OnRequestComplete(OnRequestCompleteDelegate action)
        {
            client.SetOnRequestComplete(action);

            return(this);
        }
예제 #8
0
 internal void SetOnRequestComplete(OnRequestCompleteDelegate action)
 {
     onRequestComplete = action;
 }
    public void Execute(OnRequestCompleteDelegate onComplete)
    {
        if (Status != eRequestStatus.pending_path_find || Status != eRequestStatus.pending_server_response)
        {
            Status = eRequestStatus.pending_path_find;
            m_onCompleteCallback = onComplete;

            PathfindingSystem.AddPathRequest(m_entity.CurrentRoomKey, m_entity.Position, TargetPosition, this.OnPathComputed);
        }
    }