GetGlobalLeaderboardPage
NOTE: The friend summary data is returned for each record in the leaderboard.
NOTE: "timeBeforeReset" is only returned when the requested version is also the active version.
Method returns a page of global leaderboard results.
Leaderboards entries contain the player's score and optionally, some user-defined data associated with the score.
tip
This method allows the client to retrieve pages from within the global leaderboard list
Service | Operation |
---|---|
leaderboard | GET_GLOBAL_LEADERBOARD_PAGE |
Method Parameters
Parameter | Description |
---|---|
leaderboardId | The id of the leaderboard |
sortOrder | Sort order of page. ("HIGH_TO_LOW" or "LOW_TO_HIGH") |
startIndex | The rank at which to start the page. |
endIndex | The rank at which to end the page. |
Usage
http://localhost:3000
- C#
- C++
- Objective-C
- Java
- JavaScript
- Dart
- Cloud Code
- Raw
string leaderboardId = "default";
SortOrder sortOrder = BrainCloudSocialLeaderboard.SortOrder.HIGH_TO_LOW;
int startIndex = 0;
int endIndex = 9;
SuccessCallback successCallback = (response, cbObject) =>
{
Debug.Log(string.Format("Success | {0}", response));
};
FailureCallback failureCallback = (status, code, error, cbObject) =>
{
Debug.Log(string.Format("Failed | {0} {1} {2}", status, code, error));
};
_bc.LeaderboardService.GetGlobalLeaderboardPage(leaderboardId, sortOrder, startIndex, endIndex, successCallback, failureCallback);
const char *leaderboardId = "default";
SortOrder sortOrder = HIGH_TO_LOW;
int startIndex = 0;
int endIndex = 9;
_bc->getLeaderboardService()->getGlobalLeaderboardPage(leaderboardId, sortOrder, startIndex, endIndex, this);
NSString *leaderboardId = @"default";
SortOrder sortOrder = HIGH_TO_LOW;
int startIndex = 0;
int endIndex = 9;
BCCompletionBlock successBlock; // define callback
BCErrorCompletionBlock failureBlock; // define callback
[[_bc leaderboardService] getGlobalLeaderboardPage:leaderboardId
sortOrder:sortOrder
startIndex:startIndex
endIndex:endIndex
completionBlock:successBlock
errorCompletionBlock:failureBlock
cbObject:nil];
String leaderboardId = "default";
SortOrder sortOrder = BrainCloudSocialLeaderboardService.SortOrder.HIGH_TO_LOW;
int startIndex = 0;
int endIndex = 9;
this; // implements IServerCallback
_bc.getLeaderboardService().getGlobalLeaderboardPage(leaderboardId, sortOrder, startIndex, endIndex, this);
public void serverCallback(ServiceName serviceName, ServiceOperation serviceOperation, JSONObject jsonData)
{
System.out.print(String.format("Success | %s", jsonData.toString()));
}
public void serverError(ServiceName serviceName, ServiceOperation serviceOperation, int statusCode, int reasonCode, String jsonError)
{
System.out.print(String.format("Failed | %d %d %s", statusCode, reasonCode, jsonError.toString()));
}
var leaderboardId = "default";
var sortOrder = "HIGH_TO_LOW";
var startIndex = 0;
var endIndex = 9;
_bc.leaderboard.getGlobalLeaderboardPage(leaderboardId, sortOrder, startIndex, endIndex, result =>
{
var status = result.status;
console.log(status + " : " + JSON.stringify(result, null, 2));
});
var leaderboardId = "default";
var sortOrder = SortOrder.HIGH_TO_LOW;
var startIndex = 0;
var endIndex = 9;
ServerResponse result = await _bc.leaderboardService.getGlobalLeaderboardPage(leaderboardId:leaderboardId, sortOrder:sortOrder, startIndex:startIndex, endIndex:endIndex);
if (result.statusCode == 200) {
print("Success");
} else {
print("Failed ${result.error['status_message'] ?? result.error}");
}
var leaderboardId = "default";
var sortOrder = "HIGH_TO_LOW";
var startIndex = 0;
var endIndex = 9;
var leaderboardProxy = bridge.getLeaderboardServiceProxy();
var postResult = leaderboardProxy.getGlobalLeaderboardPage(leaderboardId, sortOrder, startIndex, endIndex);
if (postResult.status == 200) {
// Success!
}
{
"service": "leaderboard",
"operation": "GET_GLOBAL_LEADERBOARD_PAGE",
"data": {
"leaderboardId": "default",
"sort": "HIGH_TO_LOW",
"startIndex": 0,
"endIndex": 9,
"versionId": -1
}
}
JSON Response
{
"status": 200,
"data": {
"leaderboard": [
{
"playerId": "9073dff7-0df6-437e-9be6-39cd704dcoj4",
"score": 100,
"data": null,
"createdAt": 1401385959596,
"updatedAt": 1401385959596,
"index": 0,
"rank": 1,
"name": "",
"summaryFriendData": null,
"pictureUrl": null
},
{
"playerId": "7c107e9f-ab48-492d-a000-defec6237700",
"score": 10,
"data": null,
"rewarded": false,
"createdAt": 1401385898407,
"updatedAt": 1401385898407,
"index": 1,
"rank": 2,
"name": "",
"summaryFriendData": null,
"pictureUrl": null
}
],
"moreBefore": false,
"moreAfter": true,
"timeBeforeReset": 588182412,
"server_time": 1395840957588
}
}