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; }