IEnumerator _GetScoresRoutine(int limit) { string url = string.Format("http://dreamlo.com/lb/{0}/pipe/0/{1}", keyAsset.publicKey, limit); WWW www = new WWW(url); yield return(www); if (www.text == "") { GetScoresCallback(WebCallResult.Error_NoScores, new List <DreamLoScore>()); } else { List <DreamLoScore> scores = new List <DreamLoScore>(); string[] scoreData = www.text.Split('\n'); for (int i = 0; i < scoreData.Length; i++) { scores.Add(DreamLoScore.FromString(scoreData[i])); } GetScoresCallback(WebCallResult.Success, scores); } }
IEnumerator _AddScoreRoutine(string name, int score) { string url = string.Format("http://dreamlo.com/lb/{0}/pipe-get/{1}", keyAsset.publicKey, name); WWW www = new WWW(url); yield return(www); if (www.text != "") { DreamLoScore previousScore = DreamLoScore.FromString(www.text); if (previousScore.score >= score) { AddScoreCallback(WebCallResult.Error_ScoreNotNew); yield break; } } url = string.Format("http://dreamlo.com/lb/{0}/add/{1}/{2}", keyAsset.privateKey, name, score); www = new WWW(url); yield return(www); WebCallResult result = (www.text == "OK") ? WebCallResult.Success : WebCallResult.Error; AddScoreCallback(result); }