//public void LoggedIn_LoadDataButtonPressed(OnDataReceivedCallBack OnDataReceived) // { // // GetData(OnDataReceived); // } public void GetData(OnDataReceivedCallBack OnDataReceived) { if (isLoggedIn) { StartCoroutine(SendGetDataRequest(OnDataReceived)); } }
IEnumerator SendGetDataRequest(OnDataReceivedCallBack OnDataReceived) { string data = "Error"; IEnumerator e = DCF.GetUserData(LoggedInUserName, LoggedInUserPassword); // << Send request to get the player's data string. Provides the username and password while (e.MoveNext()) { yield return(e.Current); } string response = e.Current as string; // << The returned string from the request if (response == "Error") { //There was another error. Automatically logs player out. This error message should never appear, but is here just in case. Debug.Log("Login error"); } else { string DataRecieved = response; data = DataRecieved; } if (OnDataReceived != null) { OnDataReceived.Invoke(data); } }
IEnumerator GetData_numerator(OnDataReceivedCallBack onDataReceived) { string data = "ERROR"; IEnumerator e = DCF.GetUserData(playerUsername, playerPassword); // << Send request to get the player's data string. Provides the username and password while (e.MoveNext()) { yield return(e.Current); } string response = e.Current as string; // << The returned string from the request if (response == "Error") { Debug.Log("Error: Unknown Error. Please try again later. GetDataProblem"); } else { //The player's data was retrieved. Goes back to loggedIn UI and displays the retrieved data in the InputField data = response; } if (onDataReceived != null) { onDataReceived.Invoke(data); } }
IEnumerator sendGetDataRequest(string username, string password, OnDataReceivedCallBack onDataReceived) { string data = "ERROR"; IEnumerator e = DCF.GetUserData(username, password); // << Send request to get the player's data string. Provides the username and password while (e.MoveNext()) { yield return(e.Current); } string response = e.Current as string; // << The returned string from the request if (response == "Error") { Debug.Log("Data Upload Error. Could be a server error. To check try again, if problem still occurs, contact us."); } else { data = response; } if (onDataReceived != null) { onDataReceived.Invoke(data); } }
public void GetData(OnDataReceivedCallBack onDataReceived) { //Called when the player hits 'Get Data' to retrieve the data string on their account. Switches UI to 'Loading...' and starts coroutine to get the players data string from the server if (isLoggedIn) { StartCoroutine(GetData_numerator(onDataReceived)); } }
public void GetData(OnDataReceivedCallBack callBack) { //called when the 'Get Data' button on the data part is pressed if (IsLoggedIn) { //ready to send request StartCoroutine(sendGetDataRequest(LoggedIn_Username, LoggedIn_Password, callBack)); //calls function to send get data request } }
IEnumerator sendGetDataRequest(string username, string password, OnDataReceivedCallBack callBack) { string data = "ERROR"; IEnumerator eeee = DCF.GetUserData(username, password); while (eeee.MoveNext()) { yield return(eeee.Current); } //WWW returnedddd = eeee.Current as WWW; string returnedddd = eeee.Current as string; if (returnedddd == "Error") { //Error occurred. For more information of the error, DC.Login could //be used with the same username and password Debug.Log("Data Upload Error. Could be a server error. To check try again, if problem still occurs, contact us."); } else { if (returnedddd == "ContainsUnsupportedSymbol") { //One of the parameters contained a - symbol Debug.Log("Get Data Error: Contains Unsupported Symbol '-'"); } else { //Data received in returned.text variable string DataRecieved = returnedddd; data = DataRecieved; } } if (callBack != null) { callBack.Invoke(data); } }