API Reference of GS2-Ranking SDK for Game Engine
Model
EzCategoryModel
Category Model
Different rankings can be created for different categories.
Categories can have a minimum and maximum score that can be registered, and scores outside of that range are discarded. When calculating rankings, it is possible to set whether the scores are to be ranked in ascending or descending order, with the smallest scores being ranked higher (ascending order) or the largest scores being ranked lower (descending order).
You can select global
or scope
as the type of ranking.
Global is a ranking where all players see the same results, and Scope is a ranking where each game player has a different result, such as a ranking among friends or a ranking in a guild.
For global ranking, you can set the ranking interval from 15 minutes to 24 hours for each category. Scope rankings reflect the calculate results in real time.
The ranking data has a setting called “generation,” and the registered scores can be reset by changing the generation.
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
name | string | ✓ | ~ 128 chars | Category Name | |
metadata | string | ~ 1024 chars | metadata | ||
scope | enum { “global”, “scoped” } | ✓ | ~ 128 chars | Type of Ranking | |
globalRankingSetting | EzGlobalRankingSetting | {scope} == “global” | Global Ranking Setting | ||
entryPeriodEventId | string | ~ 1024 chars | Period during which scores can be registered GS2-Schedule Event GRN | ||
accessPeriodEventId | string | ~ 1024 chars | Period during which ranking data can be accessed GS2-Schedule Event GRN |
Enumeration type definition to specify as scope
Enumerator String Definition | Description |
---|---|
global | Global |
scoped | Scoped |
EzGlobalRankingSetting
Global Ranking Setting
Global is a ranking where all players see the same results. The ranking interval can be set from 15 minutes to 24 hours.
The ranking data has a setting called “generation,” and the registered scores can be reset by changing the generation.
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
calculateIntervalMinutes | int | ✓ | 15 ~ 1440 | Interval between score totals (minutes) | |
additionalScopes | List<EzScope> | ~ 10 items | List of Scope |
EzScope
Aggregate Scope
Available in Global Ranking mode. Normally, the global ranking is calculated for all registered scores.
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
name | string | ✓ | ~ 128 chars | Scope Name | |
targetDays | long | ✓ | 1 ~ 365 | Number of days to aggregate |
EzScore
Score
This entity holds the registered scores for each game player x category.
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
categoryName | string | ✓ | ~ 128 chars | Category Name | |
userId | string | ✓ | ~ 128 chars | User Id | |
uniqueId | string | ✓ | UUID | ~ 36 chars | Score Unique ID |
scorerUserId | string | ✓ | ~ 128 chars | User Id | |
score | long | ✓ | ~ 9223372036854775805 | Score | |
metadata | string | ~ 512 chars | metadata |
EzRanking
Ranking
There are two types of ranking: global ranking, in which all participants compete on the same board, and scope ranking, in which players compete against the scores of subscribed players.
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
rank | long | ✓ | 1 ~ 9223372036854775805 | Rank | |
index | long | ✓ | ~ 9223372036854775805 | Index from 1st place | |
userId | string | ✓ | ~ 128 chars | User Id | |
score | long | ✓ | ~ 9223372036854775805 | Score | |
metadata | string | ~ 512 chars | metadata | ||
createdAt | long | ✓ | Created At (Unix time unit:milliseconds) |
EzSubscribeUser
User ID of the subscribing user
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
userId | string | ✓ | ~ 128 chars | User Id | |
targetUserId | string | ✓ | ~ 128 chars | User ID of the target to subscribe to |
Methods
getCategory
Get Category
Request
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
namespaceName | string | ✓ | ~ 128 chars | Namespace name | |
categoryName | string | ✓ | ~ 128 chars | Category Name |
Result
Type | Description | |
---|---|---|
item | EzCategoryModel | Category Model |
Implementation Example
var domain = gs2.Ranking.Namespace(
namespaceName: "namespace-0001"
).CategoryModel(
categoryName: "category-0001"
);
var item = await domain.ModelAsync();
var domain = gs2.Ranking.Namespace(
namespaceName: "namespace-0001"
).CategoryModel(
categoryName: "category-0001"
);
var future = domain.ModelFuture();
yield return future;
var item = future.Result;
const auto Domain = Gs2->Ranking->Namespace(
"namespace-0001" // namespaceName
)->CategoryModel(
"category-0001" // categoryName
);
const auto Future = Domain->Model();
Future->StartSynchronousTask();
if (Future->GetTask().IsError())
{
return false;
}
Value change event handling
var domain = gs2.Ranking.Namespace(
namespaceName: "namespace-0001"
).CategoryModel(
categoryName: "category-0001"
);
// Start event handling
var callbackId = domain.Subscribe(
value => {
// Called when the value changes
// The "value" is passed the value after the change.
}
);
// Stop event handling
domain.Unsubscribe(callbackId);
var domain = gs2.Ranking.Namespace(
namespaceName: "namespace-0001"
).CategoryModel(
categoryName: "category-0001"
);
var future = domain.ModelFuture();
yield return future;
var item = future.Result;
const auto Domain = Gs2->Ranking->Namespace(
"namespace-0001" // namespaceName
)->CategoryModel(
"category-0001" // categoryName
);
// Start event handling
const auto CallbackId = Domain->Subscribe(
[](TSharedPtr<Gs2::Ranking::Model::FCategoryModel> value) {
// Called when the value changes
// The "value" is passed the value after the change.
}
);
// Stop event handling
Domain->Unsubscribe(CallbackId);
Warning
This event is called when the value in the local cache that the SDK has is changed.
The local cache will only be changed by executing the SDK’s API, or by executing a stamp sheet via GS2-Distributor with GS2-Gateway notification enabled, or by executing a GS2-JobQueue with GS2-Gateway notification enabled. GS2-Gateway notification enabled.
Therefore, callbacks will not be invoked if the value is changed in any other way.
listCategories
Get list of categories
Request
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
namespaceName | string | ✓ | ~ 128 chars | Namespace name |
Result
Type | Description | |
---|---|---|
items | List<EzCategoryModel> | List of Category Models |
Implementation Example
var domain = gs2.Ranking.Namespace(
namespaceName: "namespace-0001"
);
var items = await domain.CategoryModelsAsync(
).ToListAsync();
var domain = gs2.Ranking.Namespace(
namespaceName: "namespace-0001"
);
var it = domain.CategoryModels(
);
List<EzCategoryModel> items = new List<EzCategoryModel>();
while (it.HasNext())
{
yield return it.Next();
if (it.Error != null)
{
onError.Invoke(it.Error, null);
break;
}
if (it.Current != null)
{
items.Add(it.Current);
}
else
{
break;
}
}
const auto Domain = Gs2->Ranking->Namespace(
"namespace-0001" // namespaceName
);
const auto It = Domain->CategoryModels(
);
TArray<Gs2::UE5::Ranking::Model::FEzCategoryModelPtr> Result;
for (auto Item : *It)
{
if (Item.IsError())
{
return false;
}
Result.Add(Item.Current());
}
Value change event handling
var domain = gs2.Ranking.Namespace(
namespaceName: "namespace-0001"
);
// Start event handling
var callbackId = domain.SubscribeCategoryModels(
() => {
// Called when an element of the list changes.
}
);
// Stop event handling
domain.UnsubscribeCategoryModels(callbackId);
var domain = gs2.Ranking.Namespace(
namespaceName: "namespace-0001"
);
var it = domain.CategoryModels(
);
List<EzCategoryModel> items = new List<EzCategoryModel>();
while (it.HasNext())
{
yield return it.Next();
if (it.Error != null)
{
onError.Invoke(it.Error, null);
break;
}
if (it.Current != null)
{
items.Add(it.Current);
}
else
{
break;
}
}
const auto Domain = Gs2->Ranking->Namespace(
"namespace-0001" // namespaceName
);
// Start event handling
const auto CallbackId = Domain->SubscribeCategoryModels(
[]() {
// Called when an element of the list changes.
}
);
// Stop event handling
Domain->UnsubscribeCategoryModels(CallbackId);
Warning
This event is called when the value in the local cache that the SDK has is changed.
The local cache will only be changed by executing the SDK’s API, or by executing a stamp sheet via GS2-Distributor with GS2-Gateway notification enabled, or by executing a GS2-JobQueue with GS2-Gateway notification enabled. GS2-Gateway notification enabled.
Therefore, callbacks will not be invoked if the value is changed in any other way.
listSubscribes
Get list of subscribed user IDs
Request
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
namespaceName | string | ✓ | ~ 128 chars | Namespace name | |
categoryName | string | ✓ | ~ 128 chars | Category Name | |
accessToken | string | ✓ | ~ 128 chars | User Id |
Result
Type | Description | |
---|---|---|
items | List<EzSubscribeUser> | List of user IDs of subscribing users |
Implementation Example
var domain = gs2.Ranking.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).RankingCategory(
categoryName: "category-0001",
additionalScopeName: null
);
var items = await domain.SubscribeUsersAsync(
).ToListAsync();
var domain = gs2.Ranking.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).RankingCategory(
categoryName: "category-0001",
additionalScopeName: null
);
var it = domain.SubscribeUsers(
);
List<EzSubscribeUser> items = new List<EzSubscribeUser>();
while (it.HasNext())
{
yield return it.Next();
if (it.Error != null)
{
onError.Invoke(it.Error, null);
break;
}
if (it.Current != null)
{
items.Add(it.Current);
}
else
{
break;
}
}
const auto Domain = Gs2->Ranking->Namespace(
"namespace-0001" // namespaceName
)->Me(
GameSession
)->RankingCategory(
"category-0001", // categoryName
nullptr // additionalScopeName
);
const auto It = Domain->SubscribeUsers(
);
TArray<Gs2::UE5::Ranking::Model::FEzSubscribeUserPtr> Result;
for (auto Item : *It)
{
if (Item.IsError())
{
return false;
}
Result.Add(Item.Current());
}
Value change event handling
var domain = gs2.Ranking.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).RankingCategory(
categoryName: "category-0001",
additionalScopeName: null
);
// Start event handling
var callbackId = domain.SubscribeSubscribeUsers(
() => {
// Called when an element of the list changes.
}
);
// Stop event handling
domain.UnsubscribeSubscribeUsers(callbackId);
var domain = gs2.Ranking.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).RankingCategory(
categoryName: "category-0001",
additionalScopeName: null
);
var it = domain.SubscribeUsers(
);
List<EzSubscribeUser> items = new List<EzSubscribeUser>();
while (it.HasNext())
{
yield return it.Next();
if (it.Error != null)
{
onError.Invoke(it.Error, null);
break;
}
if (it.Current != null)
{
items.Add(it.Current);
}
else
{
break;
}
}
const auto Domain = Gs2->Ranking->Namespace(
"namespace-0001" // namespaceName
)->Me(
GameSession
)->RankingCategory(
"category-0001", // categoryName
nullptr // additionalScopeName
);
// Start event handling
const auto CallbackId = Domain->SubscribeSubscribeUsers(
[]() {
// Called when an element of the list changes.
}
);
// Stop event handling
Domain->UnsubscribeSubscribeUsers(CallbackId);
Warning
This event is called when the value in the local cache that the SDK has is changed.
The local cache will only be changed by executing the SDK’s API, or by executing a stamp sheet via GS2-Distributor with GS2-Gateway notification enabled, or by executing a GS2-JobQueue with GS2-Gateway notification enabled. GS2-Gateway notification enabled.
Therefore, callbacks will not be invoked if the value is changed in any other way.
subscribe
Subscribe to target user
By subscribing to a target user, you can be notified of new messages posted by that user. You can choose to be notified only for messages with a specific value for the category attached to the message, or If you are offline when you receive a notification, you can set up a mobile push notification to be forwarded to you.
Request
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
namespaceName | string | ✓ | ~ 128 chars | Namespace name | |
categoryName | string | ✓ | ~ 128 chars | Category Name | |
accessToken | string | ✓ | ~ 128 chars | User Id | |
targetUserId | string | ✓ | ~ 128 chars | Target User ID |
Result
Type | Description | |
---|---|---|
item | EzSubscribeUser | Subscribed target users |
Implementation Example
var domain = gs2.Ranking.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).RankingCategory(
categoryName: "category-0001",
additionalScopeName: null
);
var result = await domain.SubscribeAsync(
targetUserId: "user-0002"
);
var item = await result.ModelAsync();
var domain = gs2.Ranking.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).RankingCategory(
categoryName: "category-0001",
additionalScopeName: null
);
var future = domain.SubscribeFuture(
targetUserId: "user-0002"
);
yield return future;
if (future.Error != null)
{
onError.Invoke(future.Error, null);
yield break;
}
var future2 = future.Result.ModelFuture();
yield return future2;
if (future2.Error != null)
{
onError.Invoke(future2.Error, null);
yield break;
}
var result = future2.Result;
const auto Domain = Gs2->Ranking->Namespace(
"namespace-0001" // namespaceName
)->Me(
GameSession
)->RankingCategory(
"category-0001", // categoryName
nullptr // additionalScopeName
);
const auto Future = Domain->Subscribe(
"user-0002" // targetUserId
);
Future->StartSynchronousTask();
if (Future->GetTask().IsError())
{
return false;
}
// obtain changed values / result values
const auto Future2 = Future->GetTask().Result()->Model();
Future2->StartSynchronousTask();
if (Future2->GetTask().IsError())
{
return Future2->GetTask().Error();
}
const auto Result = Future2->GetTask().Result();
unsubscribe
Unsubscribe
Request
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
namespaceName | string | ✓ | ~ 128 chars | Namespace name | |
categoryName | string | ✓ | ~ 128 chars | Category Name | |
accessToken | string | ✓ | ~ 128 chars | User Id | |
targetUserId | string | ✓ | ~ 128 chars | Target User ID |
Result
Type | Description | |
---|---|---|
item | EzSubscribeUser | Unsubscribed Subscription |
Implementation Example
var domain = gs2.Ranking.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).RankingCategory(
categoryName: "category-0001",
additionalScopeName: null
).SubscribeUser(
targetUserId: "user-0002"
);
var result = await domain.UnsubscribeAsync(
);
var domain = gs2.Ranking.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).RankingCategory(
categoryName: "category-0001",
additionalScopeName: null
).SubscribeUser(
targetUserId: "user-0002"
);
var future = domain.UnsubscribeFuture(
);
yield return future;
if (future.Error != null)
{
onError.Invoke(future.Error, null);
yield break;
}
const auto Domain = Gs2->Ranking->Namespace(
"namespace-0001" // namespaceName
)->Me(
GameSession
)->RankingCategory(
"category-0001", // categoryName
nullptr // additionalScopeName
)->SubscribeUser(
"user-0002" // targetUserId
);
const auto Future = Domain->Unsubscribe(
);
Future->StartSynchronousTask();
if (Future->GetTask().IsError())
{
return false;
}
const auto Result = Future->GetTask().Result();
getNearRanking
Obtain a ranking near the specified score
Request
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
namespaceName | string | ✓ | ~ 128 chars | Namespace name | |
categoryName | string | ✓ | ~ 128 chars | Category Name | |
additionalScopeName | string | ~ 128 chars | Scope Name | ||
score | long | ✓ | ~ 9223372036854775805 | Score |
Result
Type | Description | |
---|---|---|
items | List<EzRanking> | List of Ranking Scores |
Implementation Example
var domain = gs2.Ranking.Namespace(
namespaceName: "namespace-0001"
).User(
userId: "user-0001"
).RankingCategory(
categoryName: "category-0001",
additionalScopeName: null
);
var items = await domain.NearRankingsAsync(
score: 1000L
).ToListAsync();
var domain = gs2.Ranking.Namespace(
namespaceName: "namespace-0001"
).User(
userId: "user-0001"
).RankingCategory(
categoryName: "category-0001",
additionalScopeName: null
);
var it = domain.NearRankings(
score: 1000L
);
List<EzRanking> items = new List<EzRanking>();
while (it.HasNext())
{
yield return it.Next();
if (it.Error != null)
{
onError.Invoke(it.Error, null);
break;
}
if (it.Current != null)
{
items.Add(it.Current);
}
else
{
break;
}
}
const auto Domain = Gs2->Ranking->Namespace(
"namespace-0001" // namespaceName
)->User(
"user-0001" // userId
)->RankingCategory(
"category-0001", // categoryName
nullptr // additionalScopeName
);
const auto It = Domain->NearRankings(
1000L // score
);
TArray<Gs2::UE5::Ranking::Model::FEzRankingPtr> Result;
for (auto Item : *It)
{
if (Item.IsError())
{
return false;
}
Result.Add(Item.Current());
}
getRank
Obtain rank
Unique ID can be omitted when specifying a category where only one score can be registered per user ID
Request
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
namespaceName | string | ✓ | ~ 128 chars | Namespace name | |
categoryName | string | ✓ | ~ 128 chars | Category Name | |
additionalScopeName | string | ~ 128 chars | Scope Name | ||
scorerUserId | string | ✓ | ~ 128 chars | User ID of the user who earned the score | |
accessToken | string | ✓ | ~ 128 chars | User ID from which the ranking is obtained (used to determine the duration of the GS2-Schedule). | |
uniqueId | string | ✓ | “0” | ~ 36 chars | Score Unique ID |
Result
Type | Description | |
---|---|---|
item | EzRanking | Ranking |
Implementation Example
var domain = gs2.Ranking.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).RankingCategory(
categoryName: "category-0001",
additionalScopeName: null
).Ranking(
scorerUserId: "user-0001",
index: null
);
var item = await domain.ModelAsync(
scorerUserId : "user-0001"
);
var domain = gs2.Ranking.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).RankingCategory(
categoryName: "category-0001",
additionalScopeName: null
).Ranking(
scorerUserId: "user-0001",
index: null
);
var future = domain.Model(
scorerUserId : "user-0001"
);
yield return future;
var item = future.Result;
const auto Domain = Gs2->Ranking->Namespace(
"namespace-0001" // namespaceName
)->Me(
GameSession
)->RankingCategory(
"category-0001", // categoryName
nullptr // additionalScopeName
)->Ranking(
"user-0001", // scorerUserId
nullptr // index
);
const auto Future = Domain->Model(
"user-0001" // scorerUserId
);
Future->StartSynchronousTask();
if (Future->GetTask().IsError())
{
return false;
}
Value change event handling
var domain = gs2.Ranking.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).RankingCategory(
categoryName: "category-0001",
additionalScopeName: null
).Ranking(
scorerUserId: "user-0001",
index: null
);
// Start event handling
var callbackId = domain.Subscribe(
value => {
// Called when the value changes
// The "value" is passed the value after the change.
}
);
// Stop event handling
domain.Unsubscribe(callbackId);
var domain = gs2.Ranking.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).RankingCategory(
categoryName: "category-0001",
additionalScopeName: null
).Ranking(
scorerUserId: "user-0001",
index: null
);
var future = domain.Model(
scorerUserId : "user-0001"
);
yield return future;
var item = future.Result;
const auto Domain = Gs2->Ranking->Namespace(
"namespace-0001" // namespaceName
)->Me(
GameSession
)->RankingCategory(
"category-0001", // categoryName
nullptr // additionalScopeName
)->Ranking(
"user-0001", // scorerUserId
nullptr // index
);
// Start event handling
const auto CallbackId = Domain->Subscribe(
[](TSharedPtr<Gs2::Ranking::Model::FRanking> value) {
// Called when the value changes
// The "value" is passed the value after the change.
}
);
// Stop event handling
Domain->Unsubscribe(CallbackId);
Warning
This event is called when the value in the local cache that the SDK has is changed.
The local cache will only be changed by executing the SDK’s API, or by executing a stamp sheet via GS2-Distributor with GS2-Gateway notification enabled, or by executing a GS2-JobQueue with GS2-Gateway notification enabled. GS2-Gateway notification enabled.
Therefore, callbacks will not be invoked if the value is changed in any other way.
getRanking
Get Ranking
Request
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
namespaceName | string | ✓ | ~ 128 chars | Namespace name | |
categoryName | string | ✓ | ~ 128 chars | Category Name | |
additionalScopeName | string | ~ 128 chars | Scope Name | ||
accessToken | string | ~ 128 chars | User Id | ||
limit | int | ✓ | 30 | 1 ~ 1000 | Number of data acquired |
pageToken | string | ~ 4096 chars | Token specifying the position from which to start acquiring data | ||
startIndex | long | ~ 9223372036854775805 | Index to start retrieving rankings |
Result
Type | Description | |
---|---|---|
items | List<EzRanking> | List of Ranking Scores |
nextPageToken | string | Page token to retrieve the rest of the listing |
Implementation Example
var domain = gs2.Ranking.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).RankingCategory(
categoryName: "category-0001",
additionalScopeName: null
);
var items = await domain.RankingsAsync(
).ToListAsync();
var domain = gs2.Ranking.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).RankingCategory(
categoryName: "category-0001",
additionalScopeName: null
);
var it = domain.Rankings(
);
List<EzRanking> items = new List<EzRanking>();
while (it.HasNext())
{
yield return it.Next();
if (it.Error != null)
{
onError.Invoke(it.Error, null);
break;
}
if (it.Current != null)
{
items.Add(it.Current);
}
else
{
break;
}
}
const auto Domain = Gs2->Ranking->Namespace(
"namespace-0001" // namespaceName
)->Me(
GameSession
)->RankingCategory(
"category-0001", // categoryName
nullptr // additionalScopeName
);
const auto It = Domain->Rankings(
);
TArray<Gs2::UE5::Ranking::Model::FEzRankingPtr> Result;
for (auto Item : *It)
{
if (Item.IsError())
{
return false;
}
Result.Add(Item.Current());
}
Value change event handling
var domain = gs2.Ranking.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).RankingCategory(
categoryName: "category-0001",
additionalScopeName: null
);
// Start event handling
var callbackId = domain.SubscribeRankings(
() => {
// Called when an element of the list changes.
}
);
// Stop event handling
domain.UnsubscribeRankings(callbackId);
var domain = gs2.Ranking.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).RankingCategory(
categoryName: "category-0001",
additionalScopeName: null
);
var it = domain.Rankings(
);
List<EzRanking> items = new List<EzRanking>();
while (it.HasNext())
{
yield return it.Next();
if (it.Error != null)
{
onError.Invoke(it.Error, null);
break;
}
if (it.Current != null)
{
items.Add(it.Current);
}
else
{
break;
}
}
const auto Domain = Gs2->Ranking->Namespace(
"namespace-0001" // namespaceName
)->Me(
GameSession
)->RankingCategory(
"category-0001", // categoryName
nullptr // additionalScopeName
);
// Start event handling
const auto CallbackId = Domain->SubscribeRankings(
[]() {
// Called when an element of the list changes.
}
);
// Stop event handling
Domain->UnsubscribeRankings(CallbackId);
Warning
This event is called when the value in the local cache that the SDK has is changed.
The local cache will only be changed by executing the SDK’s API, or by executing a stamp sheet via GS2-Distributor with GS2-Gateway notification enabled, or by executing a GS2-JobQueue with GS2-Gateway notification enabled. GS2-Gateway notification enabled.
Therefore, callbacks will not be invoked if the value is changed in any other way.
putScore
Register Score
Request
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
namespaceName | string | ✓ | ~ 128 chars | Namespace name | |
categoryName | string | ✓ | ~ 128 chars | Category Name | |
accessToken | string | ✓ | ~ 128 chars | User Id | |
score | long | ✓ | ~ 9223372036854775805 | Score | |
metadata | string | ~ 512 chars | metadata |
Result
Type | Description | |
---|---|---|
item | EzScore | Registered Scores |
Implementation Example
var domain = gs2.Ranking.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).RankingCategory(
categoryName: "category-0001",
additionalScopeName: null
);
var result = await domain.PutScoreAsync(
score: 1000L,
metadata: null
);
var item = await result.ModelAsync();
var domain = gs2.Ranking.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).RankingCategory(
categoryName: "category-0001",
additionalScopeName: null
);
var future = domain.PutScoreFuture(
score: 1000L,
metadata: null
);
yield return future;
if (future.Error != null)
{
onError.Invoke(future.Error, null);
yield break;
}
var future2 = future.Result.ModelFuture();
yield return future2;
if (future2.Error != null)
{
onError.Invoke(future2.Error, null);
yield break;
}
var result = future2.Result;
const auto Domain = Gs2->Ranking->Namespace(
"namespace-0001" // namespaceName
)->Me(
GameSession
)->RankingCategory(
"category-0001", // categoryName
nullptr // additionalScopeName
);
const auto Future = Domain->PutScore(
1000L // score
// metadata
);
Future->StartSynchronousTask();
if (Future->GetTask().IsError())
{
return false;
}
// obtain changed values / result values
const auto Future2 = Future->GetTask().Result()->Model();
Future2->StartSynchronousTask();
if (Future2->GetTask().IsError())
{
return Future2->GetTask().Error();
}
const auto Result = Future2->GetTask().Result();
getScore
Retrieve scores registered by game players
Unique ID can be omitted when specifying a category where only one score can be registered per user ID
Request
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
namespaceName | string | ✓ | ~ 128 chars | Namespace name | |
categoryName | string | ✓ | ~ 128 chars | Category Name | |
accessToken | string | ✓ | ~ 128 chars | User Id | |
scorerUserId | string | ✓ | ~ 128 chars | User Id | |
uniqueId | string | ✓ | “0” | ~ 36 chars | Score Unique ID |
Result
Type | Description | |
---|---|---|
item | EzScore | Score |
Implementation Example
var domain = gs2.Ranking.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).Score(
categoryName: "category-0001",
scorerUserId: "user-0002",
uniqueId: "unique-0001"
);
var item = await domain.ModelAsync();
var domain = gs2.Ranking.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).Score(
categoryName: "category-0001",
scorerUserId: "user-0002",
uniqueId: "unique-0001"
);
var future = domain.ModelFuture();
yield return future;
var item = future.Result;
const auto Domain = Gs2->Ranking->Namespace(
"namespace-0001" // namespaceName
)->Me(
GameSession
)->Score(
"category-0001", // categoryName
"user-0002", // scorerUserId
"unique-0001" // uniqueId
);
const auto Future = Domain->Model();
Future->StartSynchronousTask();
if (Future->GetTask().IsError())
{
return false;
}
Value change event handling
var domain = gs2.Ranking.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).Score(
categoryName: "category-0001",
scorerUserId: "user-0002",
uniqueId: "unique-0001"
);
// Start event handling
var callbackId = domain.Subscribe(
value => {
// Called when the value changes
// The "value" is passed the value after the change.
}
);
// Stop event handling
domain.Unsubscribe(callbackId);
var domain = gs2.Ranking.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).Score(
categoryName: "category-0001",
scorerUserId: "user-0002",
uniqueId: "unique-0001"
);
var future = domain.ModelFuture();
yield return future;
var item = future.Result;
const auto Domain = Gs2->Ranking->Namespace(
"namespace-0001" // namespaceName
)->Me(
GameSession
)->Score(
"category-0001", // categoryName
"user-0002", // scorerUserId
"unique-0001" // uniqueId
);
// Start event handling
const auto CallbackId = Domain->Subscribe(
[](TSharedPtr<Gs2::Ranking::Model::FScore> value) {
// Called when the value changes
// The "value" is passed the value after the change.
}
);
// Stop event handling
Domain->Unsubscribe(CallbackId);
Warning
This event is called when the value in the local cache that the SDK has is changed.
The local cache will only be changed by executing the SDK’s API, or by executing a stamp sheet via GS2-Distributor with GS2-Gateway notification enabled, or by executing a GS2-JobQueue with GS2-Gateway notification enabled. GS2-Gateway notification enabled.
Therefore, callbacks will not be invoked if the value is changed in any other way.
listScores
Get list of scores registered by game players
Request
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
namespaceName | string | ✓ | ~ 128 chars | Namespace name | |
categoryName | string | ✓ | ~ 128 chars | Category Name | |
scorerUserId | string | ✓ | ~ 128 chars | User Id | |
accessToken | string | ✓ | ~ 128 chars | User Id | |
limit | int | ✓ | 30 | 1 ~ 1000 | Number of data acquired |
pageToken | string | ~ 1024 chars | Token specifying the position from which to start acquiring data |
Result
Type | Description | |
---|---|---|
items | List<EzScore> | List of Scores |
nextPageToken | string | Page token to retrieve the rest of the listing |
Implementation Example
var domain = gs2.Ranking.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
);
var items = await domain.ScoresAsync(
categoryName: "category-0001",
scorerUserId: "user-0002"
).ToListAsync();
var domain = gs2.Ranking.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
);
var it = domain.Scores(
categoryName: "category-0001",
scorerUserId: "user-0002"
);
List<EzScore> items = new List<EzScore>();
while (it.HasNext())
{
yield return it.Next();
if (it.Error != null)
{
onError.Invoke(it.Error, null);
break;
}
if (it.Current != null)
{
items.Add(it.Current);
}
else
{
break;
}
}
const auto Domain = Gs2->Ranking->Namespace(
"namespace-0001" // namespaceName
)->Me(
GameSession
);
const auto It = Domain->Scores(
"category-0001", // categoryName
"user-0002" // scorerUserId
);
TArray<Gs2::UE5::Ranking::Model::FEzScorePtr> Result;
for (auto Item : *It)
{
if (Item.IsError())
{
return false;
}
Result.Add(Item.Current());
}
Value change event handling
var domain = gs2.Ranking.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
);
// Start event handling
var callbackId = domain.SubscribeScores(
() => {
// Called when an element of the list changes.
}
);
// Stop event handling
domain.UnsubscribeScores(callbackId);
var domain = gs2.Ranking.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
);
var it = domain.Scores(
categoryName: "category-0001",
scorerUserId: "user-0002"
);
List<EzScore> items = new List<EzScore>();
while (it.HasNext())
{
yield return it.Next();
if (it.Error != null)
{
onError.Invoke(it.Error, null);
break;
}
if (it.Current != null)
{
items.Add(it.Current);
}
else
{
break;
}
}
const auto Domain = Gs2->Ranking->Namespace(
"namespace-0001" // namespaceName
)->Me(
GameSession
);
// Start event handling
const auto CallbackId = Domain->SubscribeScores(
[]() {
// Called when an element of the list changes.
}
);
// Stop event handling
Domain->UnsubscribeScores(CallbackId);
Warning
This event is called when the value in the local cache that the SDK has is changed.
The local cache will only be changed by executing the SDK’s API, or by executing a stamp sheet via GS2-Distributor with GS2-Gateway notification enabled, or by executing a GS2-JobQueue with GS2-Gateway notification enabled. GS2-Gateway notification enabled.
Therefore, callbacks will not be invoked if the value is changed in any other way.