public void data_getData_Button(OnRecievedDataCallBack onRecievedData) { //called when the 'Get Data' button on the data part is pressed if (isLoggedIn) { //ready to send request StartCoroutine(sendGetDataRequest(loggedIn_Username, loggedIn_Password, onRecievedData)); //calls function to send get data request } }
IEnumerator sendGetDataRequest(string username, string password, OnRecievedDataCallBack onRecievedData) { string data = "ERROR"; IEnumerator eeee = DatabaseControl.DCF.GetUserData(username, password); while (eeee.MoveNext()) { yield return(eeee.Current); } string returnedd = eeee.Current as string; if (returnedd == "Error") { //Error occurred. For more information of the error, DatabaseControl.DCF.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 (returnedd == "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 = returnedd; data = DataRecieved; } if (onRecievedData != null) { onRecievedData.Invoke(data); } } }