public void GetData(OnReceivedDataCallback OnDataReceived) //called when the 'Get Data' button on the data part is pressed { if (IsLoggedIn) { //ready to send request StartCoroutine(sendGetDataRequest(loggedIn_Username, loggedIn_Password, OnDataReceived)); //calls function to send get data request } }
IEnumerator sendGetDataRequest(string username, string password, OnReceivedDataCallback OnDataReceived) { string data = "ERROR"; IEnumerator eeee = DC.GetUserData(username, password); while (eeee.MoveNext()) { yield return(eeee.Current); } WWW returnedddd = eeee.Current as WWW; if (returnedddd.text == "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.text == "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.text; data = DataRecieved; } } if (OnDataReceived != null) { OnDataReceived.Invoke(data); } }