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 void OnLoginRequestComplete(AsyncJSONRequest asyncRequest)
    {
        if (asyncRequest.GetRequestState() == AsyncJSONRequest.eRequestState.succeded)
        {
            JsonData loginResponse = asyncRequest.GetResult();
            Dictionary <string, string> responseHeaders = asyncRequest.GetLoader().responseHeaders;

            if ((string)loginResponse["result"] == "Success")
            {
                SessionData sessionData = SessionData.GetInstance();

                sessionData.Authenticated = true;
                sessionData.UserName      = (string)asyncRequest.GetRequestData()["username"];

                // Save the authentication cookie, if any was sent
                if (responseHeaders.ContainsKey("SET-COOKIE"))
                {
                    sessionData.Cookie = responseHeaders["SET-COOKIE"];
                }

                m_loginController.OnLoginSucceeded();
            }
            else
            {
                m_loginController.OnLoginFailed((string)loginResponse["result"]);
            }
        }
        else
        {
            m_loginController.OnLoginFailed("Connection Failure!");
            Debug.LogError("Login Failed: " + asyncRequest.GetFailureReason());
        }

        // Free the request now that we're done with it
        AsyncJSONRequest.Destroy(asyncRequest);
        asyncRequest = null;

        LoginRequestPending = false;
    }
    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;
    }
Пример #4
0
    private void OnLoginRequestComplete(AsyncJSONRequest asyncRequest)
    {
        if (asyncRequest.GetRequestState() == AsyncJSONRequest.eRequestState.succeded)
        {
            JsonData loginResponse = asyncRequest.GetResult();
            Dictionary<string, string> responseHeaders= asyncRequest.GetLoader().responseHeaders;

            if ((string)loginResponse["result"] == "Success")
            {
                SessionData sessionData = SessionData.GetInstance();

                sessionData.Authenticated = true;
                sessionData.UserName = (string)asyncRequest.GetRequestData()["username"];

                // Save the authentication cookie, if any was sent
                if (responseHeaders.ContainsKey("SET-COOKIE"))
                {
                    sessionData.Cookie = responseHeaders["SET-COOKIE"];
                }

                m_loginController.OnLoginSucceeded();
            }
            else
            {
                m_loginController.OnLoginFailed((string)loginResponse["result"]);
            }
        }
        else
        {
            m_loginController.OnLoginFailed("Connection Failure!");
            Debug.LogError("Login Failed: " + asyncRequest.GetFailureReason());
        }

        // Free the request now that we're done with it
        AsyncJSONRequest.Destroy(asyncRequest);
        asyncRequest = null;

        LoginRequestPending = false;
    }