public static void GetLeaderboards(String leaderboardListTag, Action <List <OKLeaderboard>, OKException> requestHandler) { Dictionary <string, object> requestParams = new Dictionary <string, object>(); requestParams.Add("tag", leaderboardListTag); OKCloudAsyncRequest.Get("/leaderboards", requestParams, (JSONObject responseObj, OKCloudException e) => { if (e != null) { OKLog.Error("Getting leaderboards failed with error: " + e); requestHandler(null, e); } else { Debug.Log("Got leaderboards"); if (responseObj.type == JSONObject.Type.ARRAY) { List <OKLeaderboard> leaderboardList = new List <OKLeaderboard>(responseObj.list.Count); for (int x = 0; x < responseObj.list.Count; x++) { OKLeaderboard leaderboard = new OKLeaderboard(responseObj[x]); leaderboardList.Add(leaderboard); } requestHandler(leaderboardList, null); } else { OKLog.Error("Expected an array of leaderboards but did not get back an Array JSON"); requestHandler(null, new OKException("Expected an array of leaderboards but did not get back an Array JSON")); } } }); }
void GetMyBestScore() { OKLeaderboard leaderboard = new OKLeaderboard(); leaderboard.LeaderboardID = SampleLeaderboardID; leaderboard.GetUsersTopScore((score, err) => { if (err == null) { if (score == null) { UnityEngine.Debug.Log("User does not have a score for this leaderboard."); } else { UnityEngine.Debug.Log("Got user's best score: " + score); } } else { UnityEngine.Debug.Log("Error getting best score: " + err.Message); } }); }
public GhostScoresRequest(OKLeaderboard leaderboard) { Leaderboard = leaderboard; _pendingBufferLoad = new List<OKScore>(); _response = new OKGhostScoresResponse(); }
// TODO: This should return a reference to an obj that can cancel all requests. public void ExecuteAsync(GhostScoresDidLoadHandler handler) { _handler = handler; OKLeaderboard leaderboard = new OKLeaderboard(); leaderboard.LeaderboardID = this.LeaderboardID; // Kick off the chain... leaderboard.GetFacebookFriendsScores(FacebookFriendsScoresDidLoad); }
public static void GetLeaderboards(String leaderboardListTag, Action<List<OKLeaderboard>, OKException> requestHandler) { Dictionary<string, object> requestParams = new Dictionary<string, object>(); requestParams.Add("tag", leaderboardListTag); OKCloudAsyncRequest.Get("/leaderboards", requestParams, (JSONObject responseObj, OKCloudException e) => { if(e != null) { OKLog.Error("Getting leaderboards failed with error: " + e); requestHandler(null, e); } else { Debug.Log("Got leaderboards"); if (responseObj.type == JSONObject.Type.ARRAY) { List<OKLeaderboard> leaderboardList = new List<OKLeaderboard>(responseObj.list.Count); for(int x = 0; x < responseObj.list.Count; x++) { OKLeaderboard leaderboard = new OKLeaderboard(responseObj[x]); leaderboardList.Add(leaderboard); } requestHandler(leaderboardList, null); } else { OKLog.Error("Expected an array of leaderboards but did not get back an Array JSON"); requestHandler(null, new OKException("Expected an array of leaderboards but did not get back an Array JSON")); } } }); }
public GhostScoresRequest(OKLeaderboard leaderboard) { Leaderboard = leaderboard; _pendingBufferLoad = new List <OKScore>(); _response = new OKGhostScoresResponse(); }
void GetSocialScores() { OKLeaderboard leaderboard = new OKLeaderboard(SampleLeaderboardID); OKLog.Info("Getting scores for leaderboard ID: " + leaderboard.LeaderboardID + " named: " + leaderboard.Name); leaderboard.GetFacebookFriendsScores((List<OKScore> scores, OKException exception2) => { if(exception2 == null) { OKLog.Info("Got facebook friends scores scores in the callback"); } else { OKLog.Info("Error getting facebook friends scores: " + exception2); } }); }
void GetScoresWithMetadata() { var leaderboard = new OKLeaderboard(SampleLeaderboardID); var request = new GhostScoresRequest(leaderboard); request.Get(response => { switch (response.Status) { case OKIOStatus.Cancelled: OKLog.Info("Cancelled the ghost scores request."); break; case OKIOStatus.FailedWithError: OKLog.Info("Ghost scores request failed with error: " + response.Err.Message); break; case OKIOStatus.Succeeded: OKLog.Info("Ghost ghost scores!"); WriteMetadata(response.scores); break; } }); // Cancel the request anytime with: // request.Cancel(); // new System.Threading.Timer(CancelGhostRequest, request, 150, -1); }