API Reference of GS2-Inventory SDK for Game Engine
Model
EzInventoryModel
Inventory Model
Inventory is like a bag that stores items owned by game players. Inventory can have a set capacity and cannot be owned beyond its capacity.
The inventory capacity can be expanded. It can be set to reward stamp sheets, so any method of expansion is acceptable as long as the stamp sheets can be used to grant rewards.
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
name | string | ✓ | ~ 128 chars | Inventory Model Name | |
metadata | string | ~ 128 chars | metadata | ||
initialCapacity | int | ✓ | ~ 2147483646 | Initial Capacity | |
maxCapacity | int | ✓ | ~ 2147483646 | Maximum Capacity |
EzItemModel
Item Model
Multiple items can be owned for one capacity of inventory, such as potions x 99
.
Multiple items owned in one capacity are stacked items
. The maximum number of items that can be stacked can be specified for each item.
When the maximum stackable quantity is reached, you can set for each item whether you can reserve a new inventory capacity and own it, or whether it will no longer be available.
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
name | string | ✓ | ~ 128 chars | Item Model Name | |
metadata | string | ~ 128 chars | metadata | ||
stackingLimit | long | ✓ | 1 ~ 9223372036854775805 | Maximum stackable quantity | |
allowMultipleStacks | bool | ✓ | Allow items to be stored in multiple slots when the maximum stackable quantity is exceeded? | ||
sortValue | int | ✓ | ~ 2147483646 | Display order |
EzInventory
Inventory
Inventory is like a bag that stores items owned by game players. The bag has a capacity, and the capacity can be expanded by each player.
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
inventoryId | string | ✓ | ~ 1024 chars | Inventory GRN | |
inventoryName | string | ✓ | ~ 128 chars | Inventory Model Name | |
currentInventoryCapacityUsage | int | ✓ | 0 | ~ 2147483646 | Capacity usage |
currentInventoryMaxCapacity | int | ✓ | 1 ~ 2147483646 | Maximum capacity |
EzItemSet
Items are the property of the game player
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
itemSetId | string | ✓ | ~ 1024 chars | Quantity of items held per expiration date GRN | |
name | string | ✓ | UUID | ~ 36 chars | Name identifying the item set |
inventoryName | string | ✓ | ~ 128 chars | Inventory Model Name | |
itemName | string | ✓ | ~ 128 chars | Item Model Name | |
count | long | ✓ | 1 ~ 9223372036854775805 | Quantity in possession | |
sortValue | int | ✓ | ~ 2147483646 | Display order | |
expiresAt | long | ✓ | 0 | Effective date | |
referenceOf | List<string> | [] | ~ 24 items | List of references for this possession |
EzSimpleInventoryModel
Simple Inventory Model
In a normal InventoryModel, you could limit the amount of items that could be stored in your inventory. Simple Inventory, however, has no such functionality and simply stores the number of items in the inventory.
However, the Simple Inventory provides an API that can increase or decrease the number of items in a single process.
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
name | string | ✓ | ~ 128 chars | Simple Inventory Model Name | |
metadata | string | ~ 128 chars | metadata |
EzSimpleItemModel
Simple ItemModel
In the normal ItemModel, it is possible to set the maximum number of items that can be stacked, and if the number exceeds a certain number, it can be implemented to divide the items into multiple stacks. However, SimpleItem does not have such a function and simply stores the number of items in the possession of the item.
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
name | string | ✓ | ~ 128 chars | Simple Item Model Name | |
metadata | string | ~ 128 chars | metadata |
EzSimpleItem
Items are the property of the game player
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
itemId | string | ✓ | ~ 1024 chars | Quantity of items GRN | |
itemName | string | ✓ | ~ 128 chars | Simple Item Model Name | |
count | long | ✓ | 1 ~ 9223372036854775805 | Quantity in possession |
EzBigInventoryModel
Big Inventory model
In the normal InventoryModel and SimpleInventoryModel, the number of items that can be stored in the inventory is limited to the range of 64bit integer values. In inflationary games, you may need a wider range of values.
In the Big Inventory Model, the number of items that can be stored in the inventory can have an integer value of 1024 digits.
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
name | string | ✓ | ~ 128 chars | Big Inventory Model Name | |
metadata | string | ~ 128 chars | metadata |
EzBigItemModel
Big ItemModel
In the normal ItemModel, it is possible to set the maximum number of items that can be stacked, and if the number exceeds a certain number, it can be implemented to divide the items into multiple stacks. However, BigItem does not have such a function and simply stores the number of items in the possession of the item.
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
name | string | ✓ | ~ 128 chars | Big Item Model Name | |
metadata | string | ~ 128 chars | metadata |
EzBigItem
Items are the property of the game player
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
itemId | string | ✓ | ~ 1024 chars | Quantity of items GRN | |
itemName | string | ✓ | ~ 128 chars | Big Item Model Name | |
count | string | ✓ | ~ 1024 chars | Quantity in possession |
EzBigInventoryModel
Big Inventory model
In the normal InventoryModel and SimpleInventoryModel, the number of items that can be stored in the inventory is limited to the range of 64bit integer values. In inflationary games, you may need a wider range of values.
In the Big Inventory Model, the number of items that can be stored in the inventory can have an integer value of 1024 digits.
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
name | string | ✓ | ~ 128 chars | Big Inventory Model Name | |
metadata | string | ~ 128 chars | metadata |
EzBigItemModel
Big ItemModel
In the normal ItemModel, it is possible to set the maximum number of items that can be stacked, and if the number exceeds a certain number, it can be implemented to divide the items into multiple stacks. However, BigItem does not have such a function and simply stores the number of items in the possession of the item.
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
name | string | ✓ | ~ 128 chars | Big Item Model Name | |
metadata | string | ~ 128 chars | metadata |
EzBigItem
Items are the property of the game player
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
itemId | string | ✓ | ~ 1024 chars | Quantity of items GRN | |
itemName | string | ✓ | ~ 128 chars | Big Item Model Name | |
count | string | ✓ | ~ 1024 chars | Quantity in possession |
EzConsumeCount
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
itemName | string | ✓ | ~ 128 chars | Simple Item Model Name | |
count | long | ✓ | 1 ~ 9223372036854775805 | Quantity to be consumed |
EzAcquireCount
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
itemName | string | ✓ | ~ 128 chars | Simple Item Model Name | |
count | long | ✓ | 1 ~ 9223372036854775805 | Quantity to be obtained |
Methods
getInventoryModel
Get inventory model by specifying inventory name
Request
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
namespaceName | string | ✓ | ~ 32 chars | Namespace name | |
inventoryName | string | ✓ | ~ 128 chars | Inventory Model Name |
Result
Type | Description | |
---|---|---|
item | EzInventoryModel | Inventory Model |
Implementation Example
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
).InventoryModel(
inventoryName: "item"
);
var item = await domain.ModelAsync();
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
).InventoryModel(
inventoryName: "item"
);
var future = domain.Model();
yield return future;
var item = future.Result;
const auto Domain = Gs2->Inventory->Namespace(
"namespace-0001" // namespaceName
)->InventoryModel(
"item" // inventoryName
);
const auto Future = Domain.Model();
Future->StartSynchronousTask();
if (Future->GetTask().IsError())
{
return false;
}
Value change event handling
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
).InventoryModel(
inventoryName: "item"
);
// 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.Inventory.Namespace(
namespaceName: "namespace-0001"
).InventoryModel(
inventoryName: "item"
);
var future = domain.Model();
yield return future;
var item = future.Result;
const auto Domain = Gs2->Inventory->Namespace(
"namespace-0001" // namespaceName
)->InventoryModel(
"item" // inventoryName
);
// Start event handling
const auto CallbackId = Domain->Subscribe(
[](TSharedPtr<Gs2::Inventory::Model::FInventoryModel> 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.
listInventoryModels
Get list of inventory models
Request
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
namespaceName | string | ✓ | ~ 32 chars | Namespace name |
Result
Type | Description | |
---|---|---|
items | List<EzInventoryModel> | List of Inventory Models |
Implementation Example
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
);
var items = await domain.InventoryModelsAsync(
).ToListAsync();
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
);
var it = domain.InventoryModels(
);
List<EzInventoryModel> items = new List<EzInventoryModel>();
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->Inventory->Namespace(
"namespace-0001" // namespaceName
);
const auto It = Domain->InventoryModels(
);
for (auto Item : *It)
{
}
Value change event handling
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
);
// Start event handling
var callbackId = domain.SubscribeInventoryModels(
() => {
// Called when an element of the list changes.
}
);
// Stop event handling
domain.UnsubscribeInventoryModels(callbackId);
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
);
var it = domain.InventoryModels(
);
List<EzInventoryModel> items = new List<EzInventoryModel>();
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->Inventory->Namespace(
"namespace-0001" // namespaceName
);
// Start event handling
const auto CallbackId = Domain->SubscribeInventoryModels(
[]() {
// Called when an element of the list changes.
}
);
// Stop event handling
Domain->UnsubscribeInventoryModels(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.
getItemModel
Get item model by specifying inventory name and item name
Request
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
namespaceName | string | ✓ | ~ 32 chars | Namespace name | |
inventoryName | string | ✓ | ~ 128 chars | Inventory Model Name | |
itemName | string | ✓ | ~ 128 chars | Item Model Name |
Result
Type | Description | |
---|---|---|
item | EzItemModel |
Implementation Example
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
).InventoryModel(
inventoryName: "item"
).ItemModel(
itemName: "item-master-0001"
);
var item = await domain.ModelAsync();
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
).InventoryModel(
inventoryName: "item"
).ItemModel(
itemName: "item-master-0001"
);
var future = domain.Model();
yield return future;
var item = future.Result;
const auto Domain = Gs2->Inventory->Namespace(
"namespace-0001" // namespaceName
)->InventoryModel(
"item" // inventoryName
)->ItemModel(
"item-master-0001" // itemName
);
const auto Future = Domain.Model();
Future->StartSynchronousTask();
if (Future->GetTask().IsError())
{
return false;
}
Value change event handling
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
).InventoryModel(
inventoryName: "item"
).ItemModel(
itemName: "item-master-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.Inventory.Namespace(
namespaceName: "namespace-0001"
).InventoryModel(
inventoryName: "item"
).ItemModel(
itemName: "item-master-0001"
);
var future = domain.Model();
yield return future;
var item = future.Result;
const auto Domain = Gs2->Inventory->Namespace(
"namespace-0001" // namespaceName
)->InventoryModel(
"item" // inventoryName
)->ItemModel(
"item-master-0001" // itemName
);
// Start event handling
const auto CallbackId = Domain->Subscribe(
[](TSharedPtr<Gs2::Inventory::Model::FItemModel> 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.
listItemModels
Get list of item models by specifying the inventory name
Request
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
namespaceName | string | ✓ | ~ 32 chars | Namespace name | |
inventoryName | string | ✓ | ~ 128 chars | Inventory Model Name |
Result
Type | Description | |
---|---|---|
items | List<EzItemModel> | List of Item Model |
Implementation Example
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
).InventoryModel(
inventoryName: "item"
);
var items = await domain.ItemModelsAsync(
).ToListAsync();
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
).InventoryModel(
inventoryName: "item"
);
var it = domain.ItemModels(
);
List<EzItemModel> items = new List<EzItemModel>();
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->Inventory->Namespace(
"namespace-0001" // namespaceName
)->InventoryModel(
"item" // inventoryName
);
const auto It = Domain->ItemModels(
);
for (auto Item : *It)
{
}
Value change event handling
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
).InventoryModel(
inventoryName: "item"
);
// Start event handling
var callbackId = domain.SubscribeItemModels(
() => {
// Called when an element of the list changes.
}
);
// Stop event handling
domain.UnsubscribeItemModels(callbackId);
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
).InventoryModel(
inventoryName: "item"
);
var it = domain.ItemModels(
);
List<EzItemModel> items = new List<EzItemModel>();
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->Inventory->Namespace(
"namespace-0001" // namespaceName
)->InventoryModel(
"item" // inventoryName
);
// Start event handling
const auto CallbackId = Domain->SubscribeItemModels(
[]() {
// Called when an element of the list changes.
}
);
// Stop event handling
Domain->UnsubscribeItemModels(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.
getInventory
Get inventory information by specifying the inventory name
Request
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
namespaceName | string | ✓ | ~ 32 chars | Namespace name | |
inventoryName | string | ✓ | ~ 128 chars | Inventory Model Name | |
accessToken | string | ✓ | ~ 128 chars | User Id |
Result
Type | Description | |
---|---|---|
item | EzInventory | Inventory |
Implementation Example
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).Inventory(
inventoryName: "inventory-0001"
);
var item = await domain.ModelAsync();
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).Inventory(
inventoryName: "inventory-0001"
);
var future = domain.Model();
yield return future;
var item = future.Result;
const auto Domain = Gs2->Inventory->Namespace(
"namespace-0001" // namespaceName
)->Me(
AccessToken
)->Inventory(
"inventory-0001" // inventoryName
);
const auto Future = Domain.Model();
Future->StartSynchronousTask();
if (Future->GetTask().IsError())
{
return false;
}
Value change event handling
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).Inventory(
inventoryName: "inventory-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.Inventory.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).Inventory(
inventoryName: "inventory-0001"
);
var future = domain.Model();
yield return future;
var item = future.Result;
const auto Domain = Gs2->Inventory->Namespace(
"namespace-0001" // namespaceName
)->Me(
AccessToken
)->Inventory(
"inventory-0001" // inventoryName
);
// Start event handling
const auto CallbackId = Domain->Subscribe(
[](TSharedPtr<Gs2::Inventory::Model::FInventory> 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.
listInventories
Get Inventory List
Retrieves list of the inventory associated with a game player.
Request
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
namespaceName | string | ✓ | ~ 32 chars | Namespace name | |
accessToken | string | ✓ | ~ 128 chars | User Id | |
pageToken | string | ~ 1024 chars | Token specifying the position from which to start acquiring data | ||
limit | int | ✓ | 30 | 1 ~ 1000 | Number of data acquired |
Result
Type | Description | |
---|---|---|
items | List<EzInventory> | List of Inventories |
nextPageToken | string | Page token to retrieve the rest of the listing |
Implementation Example
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
);
var items = await domain.InventoriesAsync(
).ToListAsync();
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
);
var it = domain.Inventories(
);
List<EzInventory> items = new List<EzInventory>();
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->Inventory->Namespace(
"namespace-0001" // namespaceName
)->Me(
AccessToken
);
const auto It = Domain->Inventories(
);
for (auto Item : *It)
{
}
Value change event handling
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
);
// Start event handling
var callbackId = domain.SubscribeInventories(
() => {
// Called when an element of the list changes.
}
);
// Stop event handling
domain.UnsubscribeInventories(callbackId);
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
);
var it = domain.Inventories(
);
List<EzInventory> items = new List<EzInventory>();
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->Inventory->Namespace(
"namespace-0001" // namespaceName
)->Me(
AccessToken
);
// Start event handling
const auto CallbackId = Domain->SubscribeInventories(
[]() {
// Called when an element of the list changes.
}
);
// Stop event handling
Domain->UnsubscribeInventories(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.
consume
Consume Item
Use this if you wish to consume items from within the game.
This API is not used to increase or decrease items in conjunction with the GS2 system. This is because if the consideration is needed to purchase an item or to participate in a quest, you can set the consideration on GS2-Showcase or GS2-Quest, and then use the This is because items and other resources are automatically consumed as compensation when purchasing products or participating in quests.
Therefore, this API should be used when items are consumed for elements that do not involve GS2.
Request
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
namespaceName | string | ✓ | ~ 32 chars | Namespace name | |
inventoryName | string | ✓ | ~ 128 chars | Inventory Model Name | |
itemName | string | ✓ | ~ 128 chars | Item Model Name | |
accessToken | string | ✓ | ~ 128 chars | User Id | |
consumeCount | long | ✓ | 1 ~ 9223372036854775805 | Amount to consume | |
itemSetName | string | ~ 36 chars | Name identifying the item set |
Result
Type | Description | |
---|---|---|
items | List<EzItemSet> | List of item possession quantities per post-consumption expiration date |
itemModel | EzItemModel | Item Model |
inventory | EzInventory | Inventory |
Error
Special exceptions are defined in this API. GS2-SDK for GameEngine provides specialized exceptions derived from general exceptions to facilitate handling of errors that may need to be handled in games. Please refer to the documentation here for more information on common error types and handling methods.
Type | Base Type | Description |
---|---|---|
ConflictException | ConflictException | Item manipulation process conflicted. Retry required. |
InsufficientException | BadRequestException | Insufficient quantity of items in your possession. |
Implementation Example
try {
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).Inventory(
inventoryName: "inventory-0001"
).ItemSet(
itemName: "item-0001",
itemSetName: null
);
var result = await domain.ConsumeAsync(
consumeCount: 1L
);
var item = await result.ModelAsync();
} catch(Gs2.Gs2Inventory.Exception.Conflict e) {
// Item manipulation process conflicted. Retry required.
} catch(Gs2.Gs2Inventory.Exception.Insufficient e) {
// Insufficient quantity of items in your possession.
}
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).Inventory(
inventoryName: "inventory-0001"
).ItemSet(
itemName: "item-0001",
itemSetName: null
);
var future = domain.ConsumeFuture(
consumeCount: 1L
);
yield return future;
if (future.Error != null)
{
if (future.Error is Gs2.Gs2Inventory.Exception.ConflictException)
{
// Item manipulation process conflicted. Retry required.
}
if (future.Error is Gs2.Gs2Inventory.Exception.InsufficientException)
{
// Insufficient quantity of items in your possession.
}
onError.Invoke(future.Error, null);
yield break;
}
var future2 = future.Result.Model();
yield return future2;
if (future2.Error != null)
{
onError.Invoke(future2.Error, null);
yield break;
}
var result = future2.Result;
const auto Domain = Gs2->Inventory->Namespace(
"namespace-0001" // namespaceName
)->Me(
AccessToken
)->Inventory(
"inventory-0001" // inventoryName
)->ItemSet(
"item-0001", // itemName
nullptr // itemSetName
);
const auto Future = Domain->Consume(
1L
);
Future->StartSynchronousTask();
if (Future->GetTask().IsError())
{
if (Gs2::Inventory::Error::FConflictError::TypeString == Task->GetTask().Error()->Type())
{
// Item manipulation process conflicted. Retry required.
}
if (Gs2::Inventory::Error::FInsufficientError::TypeString == Task->GetTask().Error()->Type())
{
// Insufficient quantity of items in your possession.
}
return false;
}
// obtain changed values / result values
const auto Future2 = Future->GetTask().Result()->Model();
Future2->StartSynchronousTask();
if (!TestFalse(WHAT, Future2->GetTask().IsError())) return false;
const auto Result = Future2->GetTask().Result();
getItem
Retrieve items by specifying the inventory name and item name
Items may be divided into multiple stacks and responded to. Also, items with different expiration dates will always be in different stacks.
Request
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
namespaceName | string | ✓ | ~ 32 chars | Namespace name | |
inventoryName | string | ✓ | ~ 128 chars | Inventory Model Name | |
itemName | string | ✓ | ~ 128 chars | Item Model Name | |
accessToken | string | ✓ | ~ 128 chars | User Id |
Result
Type | Description | |
---|---|---|
items | List<EzItemSet> | List of Quantity of items held per expiration date |
itemModel | EzItemModel | Item Model |
inventory | EzInventory | inventory |
Implementation Example
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).Inventory(
inventoryName: "item"
).ItemSet(
itemName: "item-0001",
itemSetName: "itemSet-0001"
);
var item = await domain.ModelAsync();
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).Inventory(
inventoryName: "item"
).ItemSet(
itemName: "item-0001",
itemSetName: "itemSet-0001"
);
var future = domain.Model();
yield return future;
var item = future.Result;
const auto Domain = Gs2->Inventory->Namespace(
"namespace-0001" // namespaceName
)->Me(
AccessToken
)->Inventory(
"item" // inventoryName
)->ItemSet(
"item-0001", // itemName
"itemSet-0001" // itemSetName
);
const auto Future = Domain.Model();
Future->StartSynchronousTask();
if (Future->GetTask().IsError())
{
return false;
}
Value change event handling
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).Inventory(
inventoryName: "item"
).ItemSet(
itemName: "item-0001",
itemSetName: "itemSet-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.Inventory.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).Inventory(
inventoryName: "item"
).ItemSet(
itemName: "item-0001",
itemSetName: "itemSet-0001"
);
var future = domain.Model();
yield return future;
var item = future.Result;
const auto Domain = Gs2->Inventory->Namespace(
"namespace-0001" // namespaceName
)->Me(
AccessToken
)->Inventory(
"item" // inventoryName
)->ItemSet(
"item-0001", // itemName
"itemSet-0001" // itemSetName
);
// Start event handling
const auto CallbackId = Domain->Subscribe(
[](TSharedPtr<Gs2::Inventory::Model::FItemSet> 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.
getItemWithSignature
Retrieve signed items by specifying the inventory name and item name
This API allows you to prove that you own the item at the moment you call the API
Request
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
namespaceName | string | ✓ | ~ 32 chars | Namespace name | |
inventoryName | string | ✓ | ~ 128 chars | Inventory Model Name | |
itemName | string | ✓ | ~ 128 chars | Item Model Name | |
accessToken | string | ✓ | ~ 128 chars | User Id | |
itemSetName | string | ~ 36 chars | Name identifying the item set | ||
keyId | string | ✓ | ~ 1024 chars | encryption key GRN |
Result
Type | Description | |
---|---|---|
items | List<EzItemSet> | List of Quantity of items held per expiration date |
itemModel | EzItemModel | Item Model |
inventory | EzInventory | Inventory |
body | string | Item Set Information for Signature Subject |
signature | string | Signature |
Implementation Example
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).Inventory(
inventoryName: "inventory-0001"
).ItemSet(
itemName: "item-0001",
itemSetName: null
);
var result = await domain.GetItemWithSignatureAsync(
keyId: "key-0001"
);
var item = await result.ModelAsync();
var body = result.Body;
var signature = result.Signature;
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).Inventory(
inventoryName: "inventory-0001"
).ItemSet(
itemName: "item-0001",
itemSetName: null
);
var future = domain.GetItemWithSignatureFuture(
keyId: "key-0001"
);
yield return future;
if (future.Error != null)
{
onError.Invoke(future.Error, null);
yield break;
}
var future2 = future.Result.Model();
yield return future2;
if (future2.Error != null)
{
onError.Invoke(future2.Error, null);
yield break;
}
var result = future2.Result;
var body = future.Result.Body;
var signature = future.Result.Signature;
const auto Domain = Gs2->Inventory->Namespace(
"namespace-0001" // namespaceName
)->Me(
AccessToken
)->Inventory(
"inventory-0001" // inventoryName
)->ItemSet(
"item-0001", // itemName
nullptr // itemSetName
);
const auto Future = Domain->GetItemWithSignature(
"key-0001"
);
Future->StartSynchronousTask();
if (Future->GetTask().IsError())
{
return false;
}
// obtain changed values / result values
const auto Future2 = Future->GetTask().Result()->Model();
Future2->StartSynchronousTask();
if (!TestFalse(WHAT, Future2->GetTask().IsError())) return false;
const auto Result = Future2->GetTask().Result();
const auto Body = Result->Body;
const auto Signature = Result->Signature;
listItems
Retrieves list of items owned in the specified inventory
Request
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
namespaceName | string | ✓ | ~ 32 chars | Namespace name | |
inventoryName | string | ✓ | ~ 128 chars | Inventory Model Name | |
accessToken | string | ✓ | ~ 128 chars | User Id | |
pageToken | string | ~ 1024 chars | Token specifying the position from which to start acquiring data | ||
limit | int | ✓ | 30 | 1 ~ 1000 | Number of data acquired |
Result
Type | Description | |
---|---|---|
items | List<EzItemSet> | List of Quantity of items held per expiration date |
nextPageToken | string | Page token to retrieve the rest of the listing |
Implementation Example
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).Inventory(
inventoryName: "item"
);
var items = await domain.ItemSetsAsync(
).ToListAsync();
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).Inventory(
inventoryName: "item"
);
var it = domain.ItemSets(
);
List<EzItemSet> items = new List<EzItemSet>();
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->Inventory->Namespace(
"namespace-0001" // namespaceName
)->Me(
AccessToken
)->Inventory(
"item" // inventoryName
);
const auto It = Domain->ItemSets(
);
for (auto Item : *It)
{
}
Value change event handling
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).Inventory(
inventoryName: "item"
);
// Start event handling
var callbackId = domain.SubscribeItemSets(
() => {
// Called when an element of the list changes.
}
);
// Stop event handling
domain.UnsubscribeItemSets(callbackId);
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).Inventory(
inventoryName: "item"
);
var it = domain.ItemSets(
);
List<EzItemSet> items = new List<EzItemSet>();
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->Inventory->Namespace(
"namespace-0001" // namespaceName
)->Me(
AccessToken
)->Inventory(
"item" // inventoryName
);
// Start event handling
const auto CallbackId = Domain->SubscribeItemSets(
[]() {
// Called when an element of the list changes.
}
);
// Stop event handling
Domain->UnsubscribeItemSets(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.
getSimpleInventoryModel
Get simple inventory model by specifying inventory name
Request
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
namespaceName | string | ✓ | ~ 32 chars | Namespace name | |
inventoryName | string | ✓ | ~ 128 chars | Simple Inventory Model Name |
Result
Type | Description | |
---|---|---|
item | EzSimpleInventoryModel | Simple Inventory Model |
Implementation Example
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
).SimpleInventoryModel(
inventoryName: "item"
);
var item = await domain.ModelAsync();
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
).SimpleInventoryModel(
inventoryName: "item"
);
var future = domain.Model();
yield return future;
var item = future.Result;
const auto Domain = Gs2->Inventory->Namespace(
"namespace-0001" // namespaceName
)->SimpleInventoryModel(
"item" // inventoryName
);
const auto Future = Domain.Model();
Future->StartSynchronousTask();
if (Future->GetTask().IsError())
{
return false;
}
Value change event handling
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
).SimpleInventoryModel(
inventoryName: "item"
);
// 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.Inventory.Namespace(
namespaceName: "namespace-0001"
).SimpleInventoryModel(
inventoryName: "item"
);
var future = domain.Model();
yield return future;
var item = future.Result;
const auto Domain = Gs2->Inventory->Namespace(
"namespace-0001" // namespaceName
)->SimpleInventoryModel(
"item" // inventoryName
);
// Start event handling
const auto CallbackId = Domain->Subscribe(
[](TSharedPtr<Gs2::Inventory::Model::FSimpleInventoryModel> 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.
listSimpleInventoryModels
Get list of simple inventory models
Request
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
namespaceName | string | ✓ | ~ 32 chars | Namespace name |
Result
Type | Description | |
---|---|---|
items | List<EzSimpleInventoryModel> | List of Simple Inventory Models |
Implementation Example
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
);
var items = await domain.SimpleInventoryModelsAsync(
).ToListAsync();
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
);
var it = domain.SimpleInventoryModels(
);
List<EzSimpleInventoryModel> items = new List<EzSimpleInventoryModel>();
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->Inventory->Namespace(
"namespace-0001" // namespaceName
);
const auto It = Domain->SimpleInventoryModels(
);
for (auto Item : *It)
{
}
Value change event handling
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
);
// Start event handling
var callbackId = domain.SubscribeSimpleInventoryModels(
() => {
// Called when an element of the list changes.
}
);
// Stop event handling
domain.UnsubscribeSimpleInventoryModels(callbackId);
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
);
var it = domain.SimpleInventoryModels(
);
List<EzSimpleInventoryModel> items = new List<EzSimpleInventoryModel>();
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->Inventory->Namespace(
"namespace-0001" // namespaceName
);
// Start event handling
const auto CallbackId = Domain->SubscribeSimpleInventoryModels(
[]() {
// Called when an element of the list changes.
}
);
// Stop event handling
Domain->UnsubscribeSimpleInventoryModels(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.
getSimpleItemModel
Get simple item model by specifying inventory name and item name
Request
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
namespaceName | string | ✓ | ~ 32 chars | Namespace name | |
inventoryName | string | ✓ | ~ 128 chars | Simple Inventory Model Name | |
itemName | string | ✓ | ~ 128 chars | Simple Item Model Name |
Result
Type | Description | |
---|---|---|
item | EzSimpleItemModel |
Implementation Example
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
).SimpleInventoryModel(
inventoryName: "item"
).SimpleItemModel(
itemName: "item-master-0001"
);
var item = await domain.ModelAsync();
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
).SimpleInventoryModel(
inventoryName: "item"
).SimpleItemModel(
itemName: "item-master-0001"
);
var future = domain.Model();
yield return future;
var item = future.Result;
const auto Domain = Gs2->Inventory->Namespace(
"namespace-0001" // namespaceName
)->SimpleInventoryModel(
"item" // inventoryName
)->SimpleItemModel(
"item-master-0001" // itemName
);
const auto Future = Domain.Model();
Future->StartSynchronousTask();
if (Future->GetTask().IsError())
{
return false;
}
Value change event handling
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
).SimpleInventoryModel(
inventoryName: "item"
).SimpleItemModel(
itemName: "item-master-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.Inventory.Namespace(
namespaceName: "namespace-0001"
).SimpleInventoryModel(
inventoryName: "item"
).SimpleItemModel(
itemName: "item-master-0001"
);
var future = domain.Model();
yield return future;
var item = future.Result;
const auto Domain = Gs2->Inventory->Namespace(
"namespace-0001" // namespaceName
)->SimpleInventoryModel(
"item" // inventoryName
)->SimpleItemModel(
"item-master-0001" // itemName
);
// Start event handling
const auto CallbackId = Domain->Subscribe(
[](TSharedPtr<Gs2::Inventory::Model::FSimpleItemModel> 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.
listSimpleItemModels
Get list of simple item models by specifying the inventory name
Request
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
namespaceName | string | ✓ | ~ 32 chars | Namespace name | |
inventoryName | string | ✓ | ~ 128 chars | Simple Inventory Model Name |
Result
Type | Description | |
---|---|---|
items | List<EzSimpleItemModel> | List of Simple Item Model |
Implementation Example
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
).SimpleInventoryModel(
inventoryName: "item"
);
var items = await domain.SimpleItemModelsAsync(
).ToListAsync();
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
).SimpleInventoryModel(
inventoryName: "item"
);
var it = domain.SimpleItemModels(
);
List<EzSimpleItemModel> items = new List<EzSimpleItemModel>();
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->Inventory->Namespace(
"namespace-0001" // namespaceName
)->SimpleInventoryModel(
"item" // inventoryName
);
const auto It = Domain->SimpleItemModels(
);
for (auto Item : *It)
{
}
Value change event handling
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
).SimpleInventoryModel(
inventoryName: "item"
);
// Start event handling
var callbackId = domain.SubscribeSimpleItemModels(
() => {
// Called when an element of the list changes.
}
);
// Stop event handling
domain.UnsubscribeSimpleItemModels(callbackId);
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
).SimpleInventoryModel(
inventoryName: "item"
);
var it = domain.SimpleItemModels(
);
List<EzSimpleItemModel> items = new List<EzSimpleItemModel>();
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->Inventory->Namespace(
"namespace-0001" // namespaceName
)->SimpleInventoryModel(
"item" // inventoryName
);
// Start event handling
const auto CallbackId = Domain->SubscribeSimpleItemModels(
[]() {
// Called when an element of the list changes.
}
);
// Stop event handling
Domain->UnsubscribeSimpleItemModels(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.
consumeSimpleItems
Consume Item
Use this if you wish to consume items from within the game.
This API is not used to increase or decrease items in conjunction with the GS2 system. This is because if the consideration is needed to purchase an item or to participate in a quest, you can set the consideration on GS2-Showcase or GS2-Quest, and then use the This is because items and other resources are automatically consumed as compensation when purchasing products or participating in quests.
Therefore, this API should be used when items are consumed for elements that do not involve GS2.
Request
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
namespaceName | string | ✓ | ~ 32 chars | Namespace name | |
inventoryName | string | ✓ | ~ 128 chars | Simple Inventory Model Name | |
accessToken | string | ✓ | ~ 128 chars | User Id | |
consumeCounts | List<EzConsumeCount> | ✓ | 1 ~ 100 items | List of quantity of items to be consumed |
Result
Type | Description | |
---|---|---|
items | List<EzSimpleItem> | List of item possession quantities per post-consumption expiration date |
Error
Special exceptions are defined in this API. GS2-SDK for GameEngine provides specialized exceptions derived from general exceptions to facilitate handling of errors that may need to be handled in games. Please refer to the documentation here for more information on common error types and handling methods.
Type | Base Type | Description |
---|---|---|
ConflictException | ConflictException | Item manipulation process conflicted. Retry required. |
InsufficientException | BadRequestException | Insufficient quantity of items in your possession. |
Implementation Example
try {
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).SimpleInventory(
inventoryName: "inventory-0001"
);
var result = await domain.ConsumeSimpleItemsAsync(
consumeCounts: new Gs2.Unity.Gs2Inventory.Model.EzConsumeCount[] {
new Gs2.Unity.Gs2Inventory.Model.EzConsumeCount
{
ItemName = "item-0001",
Count = 5,
},
new Gs2.Unity.Gs2Inventory.Model.EzConsumeCount
{
ItemName = "item-0002",
Count = 3,
},
}
);
var item = await result.ModelAsync();
} catch(Gs2.Gs2Inventory.Exception.Conflict e) {
// Item manipulation process conflicted. Retry required.
} catch(Gs2.Gs2Inventory.Exception.Insufficient e) {
// Insufficient quantity of items in your possession.
}
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).SimpleInventory(
inventoryName: "inventory-0001"
);
var future = domain.ConsumeSimpleItemsFuture(
consumeCounts: new Gs2.Unity.Gs2Inventory.Model.EzConsumeCount[] {
new Gs2.Unity.Gs2Inventory.Model.EzConsumeCount
{
ItemName = "item-0001",
Count = 5,
},
new Gs2.Unity.Gs2Inventory.Model.EzConsumeCount
{
ItemName = "item-0002",
Count = 3,
},
}
);
yield return future;
if (future.Error != null)
{
if (future.Error is Gs2.Gs2Inventory.Exception.ConflictException)
{
// Item manipulation process conflicted. Retry required.
}
if (future.Error is Gs2.Gs2Inventory.Exception.InsufficientException)
{
// Insufficient quantity of items in your possession.
}
onError.Invoke(future.Error, null);
yield break;
}
var future2 = future.Result.Model();
yield return future2;
if (future2.Error != null)
{
onError.Invoke(future2.Error, null);
yield break;
}
var result = future2.Result;
const auto Domain = Gs2->Inventory->Namespace(
"namespace-0001" // namespaceName
)->Me(
AccessToken
)->SimpleInventory(
"inventory-0001" // inventoryName
);
const auto Future = Domain->ConsumeSimpleItems(
[]
{
const auto v = MakeShared<TArray<TSharedPtr<Gs2::Inventory::Model::FConsumeCount>>>();
v->Add({'itemName': 'item-0001', 'count': 5});
v->Add({'itemName': 'item-0002', 'count': 3});
return v;
}()
);
Future->StartSynchronousTask();
if (Future->GetTask().IsError())
{
if (Gs2::Inventory::Error::FConflictError::TypeString == Task->GetTask().Error()->Type())
{
// Item manipulation process conflicted. Retry required.
}
if (Gs2::Inventory::Error::FInsufficientError::TypeString == Task->GetTask().Error()->Type())
{
// Insufficient quantity of items in your possession.
}
return false;
}
// obtain changed values / result values
const auto Future2 = Future->GetTask().Result()->Model();
Future2->StartSynchronousTask();
if (!TestFalse(WHAT, Future2->GetTask().IsError())) return false;
const auto Result = Future2->GetTask().Result();
getSimpleItem
Retrieve items by specifying the inventory name and item name
Items may be divided into multiple stacks and responded to. Also, items with different expiration dates will always be in different stacks.
Request
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
namespaceName | string | ✓ | ~ 32 chars | Namespace name | |
inventoryName | string | ✓ | ~ 128 chars | Simple Inventory Model Name | |
itemName | string | ✓ | ~ 128 chars | Simple Item Model Name | |
accessToken | string | ✓ | ~ 128 chars | User Id |
Result
Type | Description | |
---|---|---|
item | EzSimpleItem | Quantity of items |
itemModel | EzSimpleItemModel | Simple Item Model |
Implementation Example
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).SimpleInventory(
inventoryName: "item"
).SimpleItem(
itemName: "item-0001"
);
var item = await domain.ModelAsync();
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).SimpleInventory(
inventoryName: "item"
).SimpleItem(
itemName: "item-0001"
);
var future = domain.Model();
yield return future;
var item = future.Result;
const auto Domain = Gs2->Inventory->Namespace(
"namespace-0001" // namespaceName
)->Me(
AccessToken
)->SimpleInventory(
"item" // inventoryName
)->SimpleItem(
"item-0001" // itemName
);
const auto Future = Domain.Model();
Future->StartSynchronousTask();
if (Future->GetTask().IsError())
{
return false;
}
Value change event handling
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).SimpleInventory(
inventoryName: "item"
).SimpleItem(
itemName: "item-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.Inventory.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).SimpleInventory(
inventoryName: "item"
).SimpleItem(
itemName: "item-0001"
);
var future = domain.Model();
yield return future;
var item = future.Result;
const auto Domain = Gs2->Inventory->Namespace(
"namespace-0001" // namespaceName
)->Me(
AccessToken
)->SimpleInventory(
"item" // inventoryName
)->SimpleItem(
"item-0001" // itemName
);
// Start event handling
const auto CallbackId = Domain->Subscribe(
[](TSharedPtr<Gs2::Inventory::Model::FSimpleItem> 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.
getSimpleItemWithSignature
Retrieve signed items by specifying the inventory name and item name
This API allows you to prove that you own the item at the moment you call the API
Request
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
namespaceName | string | ✓ | ~ 32 chars | Namespace name | |
inventoryName | string | ✓ | ~ 128 chars | Simple Inventory Model Name | |
itemName | string | ✓ | ~ 128 chars | Simple Item Model Name | |
accessToken | string | ✓ | ~ 128 chars | User Id | |
keyId | string | ✓ | ~ 1024 chars | encryption key GRN |
Result
Type | Description | |
---|---|---|
item | EzSimpleItem | Quantity of items |
simpleItemModel | EzSimpleItemModel | Simple Item Model |
body | string | Item Set Information for Signature Subject |
signature | string | Signature |
Implementation Example
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).SimpleInventory(
inventoryName: "inventory-0001"
).SimpleItem(
itemName: "item-0001"
);
var result = await domain.GetSimpleItemWithSignatureAsync(
keyId: "key-0001"
);
var item = await result.ModelAsync();
var body = result.Body;
var signature = result.Signature;
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).SimpleInventory(
inventoryName: "inventory-0001"
).SimpleItem(
itemName: "item-0001"
);
var future = domain.GetSimpleItemWithSignatureFuture(
keyId: "key-0001"
);
yield return future;
if (future.Error != null)
{
onError.Invoke(future.Error, null);
yield break;
}
var future2 = future.Result.Model();
yield return future2;
if (future2.Error != null)
{
onError.Invoke(future2.Error, null);
yield break;
}
var result = future2.Result;
var body = future.Result.Body;
var signature = future.Result.Signature;
const auto Domain = Gs2->Inventory->Namespace(
"namespace-0001" // namespaceName
)->Me(
AccessToken
)->SimpleInventory(
"inventory-0001" // inventoryName
)->SimpleItem(
"item-0001" // itemName
);
const auto Future = Domain->GetSimpleItemWithSignature(
"key-0001"
);
Future->StartSynchronousTask();
if (Future->GetTask().IsError())
{
return false;
}
// obtain changed values / result values
const auto Future2 = Future->GetTask().Result()->Model();
Future2->StartSynchronousTask();
if (!TestFalse(WHAT, Future2->GetTask().IsError())) return false;
const auto Result = Future2->GetTask().Result();
const auto Body = Result->Body;
const auto Signature = Result->Signature;
listSimpleItems
Retrieves list of items owned in the specified inventory
Request
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
namespaceName | string | ✓ | ~ 32 chars | Namespace name | |
inventoryName | string | ✓ | ~ 128 chars | Simple Inventory Model Name | |
accessToken | string | ✓ | ~ 128 chars | User Id | |
pageToken | string | ~ 1024 chars | Token specifying the position from which to start acquiring data | ||
limit | int | ✓ | 30 | 1 ~ 1000 | Number of data acquired |
Result
Type | Description | |
---|---|---|
items | List<EzSimpleItem> | List of Quantity of items |
nextPageToken | string | Page token to retrieve the rest of the listing |
Implementation Example
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).SimpleInventory(
inventoryName: "item"
);
var items = await domain.SimpleItemsAsync(
).ToListAsync();
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).SimpleInventory(
inventoryName: "item"
);
var it = domain.SimpleItems(
);
List<EzSimpleItem> items = new List<EzSimpleItem>();
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->Inventory->Namespace(
"namespace-0001" // namespaceName
)->Me(
AccessToken
)->SimpleInventory(
"item" // inventoryName
);
const auto It = Domain->SimpleItems(
);
for (auto Item : *It)
{
}
Value change event handling
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).SimpleInventory(
inventoryName: "item"
);
// Start event handling
var callbackId = domain.SubscribeSimpleItems(
() => {
// Called when an element of the list changes.
}
);
// Stop event handling
domain.UnsubscribeSimpleItems(callbackId);
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).SimpleInventory(
inventoryName: "item"
);
var it = domain.SimpleItems(
);
List<EzSimpleItem> items = new List<EzSimpleItem>();
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->Inventory->Namespace(
"namespace-0001" // namespaceName
)->Me(
AccessToken
)->SimpleInventory(
"item" // inventoryName
);
// Start event handling
const auto CallbackId = Domain->SubscribeSimpleItems(
[]() {
// Called when an element of the list changes.
}
);
// Stop event handling
Domain->UnsubscribeSimpleItems(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.
getBigInventoryModel
Get big inventory model by specifying inventory name
Request
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
namespaceName | string | ✓ | ~ 32 chars | Namespace name | |
inventoryName | string | ✓ | ~ 128 chars | Big Inventory Model Name |
Result
Type | Description | |
---|---|---|
item | EzBigInventoryModel | Big Inventory Model |
Implementation Example
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
).BigInventoryModel(
inventoryName: "item"
);
var item = await domain.ModelAsync();
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
).BigInventoryModel(
inventoryName: "item"
);
var future = domain.Model();
yield return future;
var item = future.Result;
const auto Domain = Gs2->Inventory->Namespace(
"namespace-0001" // namespaceName
)->BigInventoryModel(
"item" // inventoryName
);
const auto Future = Domain.Model();
Future->StartSynchronousTask();
if (Future->GetTask().IsError())
{
return false;
}
Value change event handling
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
).BigInventoryModel(
inventoryName: "item"
);
// 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.Inventory.Namespace(
namespaceName: "namespace-0001"
).BigInventoryModel(
inventoryName: "item"
);
var future = domain.Model();
yield return future;
var item = future.Result;
const auto Domain = Gs2->Inventory->Namespace(
"namespace-0001" // namespaceName
)->BigInventoryModel(
"item" // inventoryName
);
// Start event handling
const auto CallbackId = Domain->Subscribe(
[](TSharedPtr<Gs2::Inventory::Model::FBigInventoryModel> 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.
listBigInventoryModels
Get list of big inventory models
Request
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
namespaceName | string | ✓ | ~ 32 chars | Namespace name |
Result
Type | Description | |
---|---|---|
items | List<EzBigInventoryModel> | List of Big Inventory Models |
Implementation Example
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
);
var items = await domain.BigInventoryModelsAsync(
).ToListAsync();
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
);
var it = domain.BigInventoryModels(
);
List<EzBigInventoryModel> items = new List<EzBigInventoryModel>();
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->Inventory->Namespace(
"namespace-0001" // namespaceName
);
const auto It = Domain->BigInventoryModels(
);
for (auto Item : *It)
{
}
Value change event handling
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
);
// Start event handling
var callbackId = domain.SubscribeBigInventoryModels(
() => {
// Called when an element of the list changes.
}
);
// Stop event handling
domain.UnsubscribeBigInventoryModels(callbackId);
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
);
var it = domain.BigInventoryModels(
);
List<EzBigInventoryModel> items = new List<EzBigInventoryModel>();
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->Inventory->Namespace(
"namespace-0001" // namespaceName
);
// Start event handling
const auto CallbackId = Domain->SubscribeBigInventoryModels(
[]() {
// Called when an element of the list changes.
}
);
// Stop event handling
Domain->UnsubscribeBigInventoryModels(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.
getBigItemModel
Get big item model by specifying inventory name and item name
Request
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
namespaceName | string | ✓ | ~ 32 chars | Namespace name | |
inventoryName | string | ✓ | ~ 128 chars | Big Inventory Model Name | |
itemName | string | ✓ | ~ 128 chars | Big Item Model Name |
Result
Type | Description | |
---|---|---|
item | EzBigItemModel |
Implementation Example
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
).BigInventoryModel(
inventoryName: "item"
).BigItemModel(
itemName: "item-master-0001"
);
var item = await domain.ModelAsync();
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
).BigInventoryModel(
inventoryName: "item"
).BigItemModel(
itemName: "item-master-0001"
);
var future = domain.Model();
yield return future;
var item = future.Result;
const auto Domain = Gs2->Inventory->Namespace(
"namespace-0001" // namespaceName
)->BigInventoryModel(
"item" // inventoryName
)->BigItemModel(
"item-master-0001" // itemName
);
const auto Future = Domain.Model();
Future->StartSynchronousTask();
if (Future->GetTask().IsError())
{
return false;
}
Value change event handling
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
).BigInventoryModel(
inventoryName: "item"
).BigItemModel(
itemName: "item-master-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.Inventory.Namespace(
namespaceName: "namespace-0001"
).BigInventoryModel(
inventoryName: "item"
).BigItemModel(
itemName: "item-master-0001"
);
var future = domain.Model();
yield return future;
var item = future.Result;
const auto Domain = Gs2->Inventory->Namespace(
"namespace-0001" // namespaceName
)->BigInventoryModel(
"item" // inventoryName
)->BigItemModel(
"item-master-0001" // itemName
);
// Start event handling
const auto CallbackId = Domain->Subscribe(
[](TSharedPtr<Gs2::Inventory::Model::FBigItemModel> 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.
listBigItemModels
Get list of big item models by specifying the inventory name
Request
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
namespaceName | string | ✓ | ~ 32 chars | Namespace name | |
inventoryName | string | ✓ | ~ 128 chars | Big Inventory Model Name |
Result
Type | Description | |
---|---|---|
items | List<EzBigItemModel> | List of Big Item Model |
Implementation Example
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
).BigInventoryModel(
inventoryName: "item"
);
var items = await domain.BigItemModelsAsync(
).ToListAsync();
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
).BigInventoryModel(
inventoryName: "item"
);
var it = domain.BigItemModels(
);
List<EzBigItemModel> items = new List<EzBigItemModel>();
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->Inventory->Namespace(
"namespace-0001" // namespaceName
)->BigInventoryModel(
"item" // inventoryName
);
const auto It = Domain->BigItemModels(
);
for (auto Item : *It)
{
}
Value change event handling
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
).BigInventoryModel(
inventoryName: "item"
);
// Start event handling
var callbackId = domain.SubscribeBigItemModels(
() => {
// Called when an element of the list changes.
}
);
// Stop event handling
domain.UnsubscribeBigItemModels(callbackId);
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
).BigInventoryModel(
inventoryName: "item"
);
var it = domain.BigItemModels(
);
List<EzBigItemModel> items = new List<EzBigItemModel>();
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->Inventory->Namespace(
"namespace-0001" // namespaceName
)->BigInventoryModel(
"item" // inventoryName
);
// Start event handling
const auto CallbackId = Domain->SubscribeBigItemModels(
[]() {
// Called when an element of the list changes.
}
);
// Stop event handling
Domain->UnsubscribeBigItemModels(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.
consumeBigItem
Consume Item
Use this if you wish to consume items from within the game.
This API is not used to increase or decrease items in conjunction with the GS2 system. This is because if the consideration is needed to purchase an item or to participate in a quest, you can set the consideration on GS2-Showcase or GS2-Quest, and then use the This is because items and other resources are automatically consumed as compensation when purchasing products or participating in quests.
Therefore, this API should be used when items are consumed for elements that do not involve GS2.
Request
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
namespaceName | string | ✓ | ~ 32 chars | Namespace name | |
inventoryName | string | ✓ | ~ 128 chars | Big Inventory Model Name | |
itemName | string | ✓ | ~ 128 chars | Big Item Model Name | |
accessToken | string | ✓ | ~ 128 chars | User Id | |
consumeCount | string | ✓ | ~ 1024 chars | Quantity of items to be consumed |
Result
Type | Description | |
---|---|---|
item | EzBigItem | Quantity of items held per post-consumption expiration date |
Error
Special exceptions are defined in this API. GS2-SDK for GameEngine provides specialized exceptions derived from general exceptions to facilitate handling of errors that may need to be handled in games. Please refer to the documentation here for more information on common error types and handling methods.
Type | Base Type | Description |
---|---|---|
ConflictException | ConflictException | Item manipulation process conflicted. Retry required. |
InsufficientException | BadRequestException | Insufficient quantity of items in your possession. |
Implementation Example
try {
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).BigInventory(
inventoryName: "inventory-0001"
).BigItem(
itemName: "item-0001"
);
var result = await domain.ConsumeBigItemAsync(
consumeCount: "1234567890123456789012345678901234567890"
);
var item = await result.ModelAsync();
} catch(Gs2.Gs2Inventory.Exception.Conflict e) {
// Item manipulation process conflicted. Retry required.
} catch(Gs2.Gs2Inventory.Exception.Insufficient e) {
// Insufficient quantity of items in your possession.
}
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).BigInventory(
inventoryName: "inventory-0001"
).BigItem(
itemName: "item-0001"
);
var future = domain.ConsumeBigItemFuture(
consumeCount: "1234567890123456789012345678901234567890"
);
yield return future;
if (future.Error != null)
{
if (future.Error is Gs2.Gs2Inventory.Exception.ConflictException)
{
// Item manipulation process conflicted. Retry required.
}
if (future.Error is Gs2.Gs2Inventory.Exception.InsufficientException)
{
// Insufficient quantity of items in your possession.
}
onError.Invoke(future.Error, null);
yield break;
}
var future2 = future.Result.Model();
yield return future2;
if (future2.Error != null)
{
onError.Invoke(future2.Error, null);
yield break;
}
var result = future2.Result;
const auto Domain = Gs2->Inventory->Namespace(
"namespace-0001" // namespaceName
)->Me(
AccessToken
)->BigInventory(
"inventory-0001" // inventoryName
)->BigItem(
"item-0001" // itemName
);
const auto Future = Domain->ConsumeBigItem(
"1234567890123456789012345678901234567890"
);
Future->StartSynchronousTask();
if (Future->GetTask().IsError())
{
if (Gs2::Inventory::Error::FConflictError::TypeString == Task->GetTask().Error()->Type())
{
// Item manipulation process conflicted. Retry required.
}
if (Gs2::Inventory::Error::FInsufficientError::TypeString == Task->GetTask().Error()->Type())
{
// Insufficient quantity of items in your possession.
}
return false;
}
// obtain changed values / result values
const auto Future2 = Future->GetTask().Result()->Model();
Future2->StartSynchronousTask();
if (!TestFalse(WHAT, Future2->GetTask().IsError())) return false;
const auto Result = Future2->GetTask().Result();
getBigItem
Retrieve items by specifying the inventory name and item name
Items may be divided into multiple stacks and responded to. Also, items with different expiration dates will always be in different stacks.
Request
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
namespaceName | string | ✓ | ~ 32 chars | Namespace name | |
inventoryName | string | ✓ | ~ 128 chars | Big Inventory Model Name | |
itemName | string | ✓ | ~ 128 chars | Big Item Model Name | |
accessToken | string | ✓ | ~ 128 chars | User Id |
Result
Type | Description | |
---|---|---|
item | EzBigItem | Quantity of items |
itemModel | EzBigItemModel | Big Item Model |
Implementation Example
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).BigInventory(
inventoryName: "item"
).BigItem(
itemName: "item-0001"
);
var item = await domain.ModelAsync();
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).BigInventory(
inventoryName: "item"
).BigItem(
itemName: "item-0001"
);
var future = domain.Model();
yield return future;
var item = future.Result;
const auto Domain = Gs2->Inventory->Namespace(
"namespace-0001" // namespaceName
)->Me(
AccessToken
)->BigInventory(
"item" // inventoryName
)->BigItem(
"item-0001" // itemName
);
const auto Future = Domain.Model();
Future->StartSynchronousTask();
if (Future->GetTask().IsError())
{
return false;
}
Value change event handling
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).BigInventory(
inventoryName: "item"
).BigItem(
itemName: "item-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.Inventory.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).BigInventory(
inventoryName: "item"
).BigItem(
itemName: "item-0001"
);
var future = domain.Model();
yield return future;
var item = future.Result;
const auto Domain = Gs2->Inventory->Namespace(
"namespace-0001" // namespaceName
)->Me(
AccessToken
)->BigInventory(
"item" // inventoryName
)->BigItem(
"item-0001" // itemName
);
// Start event handling
const auto CallbackId = Domain->Subscribe(
[](TSharedPtr<Gs2::Inventory::Model::FBigItem> 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.
listBigItems
Retrieves list of items owned in the specified inventory
Request
Type | Require | Default | Limitation | Description | |
---|---|---|---|---|---|
namespaceName | string | ✓ | ~ 32 chars | Namespace name | |
inventoryName | string | ✓ | ~ 128 chars | Big Inventory Model Name | |
accessToken | string | ✓ | ~ 128 chars | User Id | |
pageToken | string | ~ 1024 chars | Token specifying the position from which to start acquiring data | ||
limit | int | ✓ | 30 | 1 ~ 1000 | Number of data acquired |
Result
Type | Description | |
---|---|---|
items | List<EzBigItem> | List of Quantity of items |
nextPageToken | string | Page token to retrieve the rest of the listing |
Implementation Example
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).BigInventory(
inventoryName: "item"
);
var items = await domain.BigItemsAsync(
).ToListAsync();
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).BigInventory(
inventoryName: "item"
);
var it = domain.BigItems(
);
List<EzBigItem> items = new List<EzBigItem>();
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->Inventory->Namespace(
"namespace-0001" // namespaceName
)->Me(
AccessToken
)->BigInventory(
"item" // inventoryName
);
const auto It = Domain->BigItems(
);
for (auto Item : *It)
{
}
Value change event handling
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).BigInventory(
inventoryName: "item"
);
// Start event handling
var callbackId = domain.SubscribeBigItems(
() => {
// Called when an element of the list changes.
}
);
// Stop event handling
domain.UnsubscribeBigItems(callbackId);
var domain = gs2.Inventory.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).BigInventory(
inventoryName: "item"
);
var it = domain.BigItems(
);
List<EzBigItem> items = new List<EzBigItem>();
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->Inventory->Namespace(
"namespace-0001" // namespaceName
)->Me(
AccessToken
)->BigInventory(
"item" // inventoryName
);
// Start event handling
const auto CallbackId = Domain->SubscribeBigItems(
[]() {
// Called when an element of the list changes.
}
);
// Stop event handling
Domain->UnsubscribeBigItems(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.