public void LoadMoreScores(ScorePageToken token, int rowCount, Action <LeaderboardScoreData> callback) { LogUsage(); if (callback != null) { callback(new LeaderboardScoreData(token.LeaderboardId, ResponseStatus.LicenseCheckFailed)); } }
public void LoadMoreScores(ScorePageToken token, int rowCount, Action<LeaderboardScoreData> callback) { if (!IsAuthenticated()) { GooglePlayGames.OurUtils.Logger.e("LoadMoreScores can only be called after authentication."); callback(new LeaderboardScoreData(token.LeaderboardId, ResponseStatus.NotAuthorized)); return; } mClient.LoadMoreScores(token, rowCount, callback); }
/// <summary> /// Loads the more scores for the leaderboard. /// </summary> /// <remarks>The token is accessed /// by calling LoadScores() with a positive row count. /// </remarks> /// <param name="token">Token used to start loading scores.</param> /// <param name="rowCount">Max number of scores to return. /// This can be limited by the SDK.</param> /// <param name="callback">Callback to invoke when complete.</param> public void LoadMoreScores( ScorePageToken token, int rowCount, Action<LeaderboardScoreData> callback) { LogUsage(); if (callback != null) { callback(new LeaderboardScoreData( token.LeaderboardId, ResponseStatus.LicenseCheckFailed)); } }
/// <summary> /// Loads the leaderboard data. This is the "top level" call /// to load leaderboard data. A token for fetching scores is created /// based on the parameters. /// </summary> /// <param name="leaderboardId">Leaderboard identifier.</param> /// <param name="start">Start of scores location</param> /// <param name="rowCount">Row count.</param> /// <param name="collection">Collection social or public</param> /// <param name="timeSpan">Time span of leaderboard</param> /// <param name="playerId">Player identifier.</param> /// <param name="callback">Callback.</param> public void LoadLeaderboardData(string leaderboardId, LeaderboardStart start, int rowCount, LeaderboardCollection collection, LeaderboardTimeSpan timeSpan, string playerId, Action<LeaderboardScoreData> callback) { //Create a token we'll use to load scores later. NativeScorePageToken nativeToken = new NativeScorePageToken( C.LeaderboardManager_ScorePageToken( mServices.AsHandle(), leaderboardId, (Types.LeaderboardStart)start, (Types.LeaderboardTimeSpan)timeSpan, (Types.LeaderboardCollection)collection)); ScorePageToken token = new ScorePageToken(nativeToken, leaderboardId, collection, timeSpan); // First fetch the leaderboard to get the title C.LeaderboardManager_Fetch(mServices.AsHandle(), Types.DataSource.CACHE_OR_NETWORK, leaderboardId, InternalFetchCallback, Callbacks.ToIntPtr<FetchResponse>((rsp) => HandleFetch(token, rsp, playerId, rowCount, callback), FetchResponse.FromPointer)); }
internal void HandleFetchScorePage(LeaderboardScoreData data, ScorePageToken token, FetchScorePageResponse rsp, Action<LeaderboardScoreData> callback) { data.Status = (ResponseStatus)rsp.GetStatus(); // add the scores that match the criteria if (rsp.GetStatus() != Status.ResponseStatus.VALID && rsp.GetStatus() != Status.ResponseStatus.VALID_BUT_STALE) { callback(data); } NativeScorePage page = rsp.GetScorePage(); if (!page.Valid()) { callback(data); } if (page.HasNextScorePage()) { data.NextPageToken = new ScorePageToken( page.GetNextScorePageToken(), token.LeaderboardId, token.Collection, token.TimeSpan); } if (page.HasPrevScorePage()) { data.PrevPageToken = new ScorePageToken( page.GetPreviousScorePageToken(), token.LeaderboardId, token.Collection, token.TimeSpan); } foreach (NativeScoreEntry ent in page) { data.AddScore(ent.AsScore(data.Id)); } callback(data); }
/// <summary> /// Loads the score page. This is used to page through the rows /// of leaderboard scores. /// </summary> /// <param name="data">Data - partially completed result data, can be null</param> /// <param name="maxResults">Max results to return</param> /// <param name="token">Token to use for getting the score page,</param> /// <param name="callback">Callback.</param> public void LoadScorePage(LeaderboardScoreData data, int maxResults, ScorePageToken token, Action<LeaderboardScoreData> callback) { if (data == null) { data = new LeaderboardScoreData(token.LeaderboardId); } NativeScorePageToken nativeToken = (NativeScorePageToken)token.InternalObject; C.LeaderboardManager_FetchScorePage(mServices.AsHandle(), Types.DataSource.CACHE_OR_NETWORK, nativeToken.AsPointer(), (uint)maxResults, InternalFetchScorePage, Callbacks.ToIntPtr<FetchScorePageResponse>((rsp) => { HandleFetchScorePage(data, token, rsp, callback); }, FetchScorePageResponse.FromPointer) ); }
internal void HandleFetchScoreSummary(LeaderboardScoreData data, FetchScoreSummaryResponse response, string selfPlayerId, int maxResults, ScorePageToken token, Action<LeaderboardScoreData> callback) { if (response.GetStatus() != Status.ResponseStatus.VALID && response.GetStatus() != Status.ResponseStatus.VALID_BUT_STALE) { Logger.w("Error returned from fetchScoreSummary: " + response); data.Status = (ResponseStatus)response.GetStatus(); callback(data); return; } NativeScoreSummary summary = response.GetScoreSummary(); data.ApproximateCount = summary.ApproximateResults(); data.PlayerScore = summary.LocalUserScore().AsScore(data.Id, selfPlayerId); // if the maxResults is 0, no scores are needed, so we are done. if (maxResults <= 0) { callback(data); return; } LoadScorePage(data, maxResults, token, callback); }
/// <summary> /// Handles the fetch of a specific leaderboard definition. This /// is called with the expectation that the leaderboard summary and /// scores are also needed. /// </summary> /// <param name="token">token for the current fetching request.</param> /// <param name="response">Response.</param> /// <param name="selfPlayerId">Self player identifier.</param> /// <param name="maxResults">Number of scores to return.</param> /// <param name="callback">Callback.</param> internal void HandleFetch(ScorePageToken token, FetchResponse response, string selfPlayerId, int maxResults, Action<LeaderboardScoreData> callback) { LeaderboardScoreData data = new LeaderboardScoreData( token.LeaderboardId, (ResponseStatus)response.GetStatus()); if (response.GetStatus() != Status.ResponseStatus.VALID && response.GetStatus() != Status.ResponseStatus.VALID_BUT_STALE) { Logger.w("Error returned from fetch: " + response.GetStatus()); callback(data); return; } data.Title = response.Leaderboard().Title(); data.Id = token.LeaderboardId; // now fetch the summary of the leaderboard. C.LeaderboardManager_FetchScoreSummary(mServices.AsHandle(), Types.DataSource.CACHE_OR_NETWORK, token.LeaderboardId, (Types.LeaderboardTimeSpan)token.TimeSpan, (Types.LeaderboardCollection)token.Collection, InternalFetchSummaryCallback, Callbacks.ToIntPtr<FetchScoreSummaryResponse>((rsp) => HandleFetchScoreSummary(data, rsp, selfPlayerId, maxResults, token, callback), FetchScoreSummaryResponse.FromPointer) ); }