Hello,
I’m working on a process that calls an rpc that reads and writes to the database to update storage (a monster) information in the game I’m developing.
The game has a screen where it’s possible to update some monster stats like health, strength, etc. With the rpc call, the database is updated, and these stats are correctly displayed on that screen to the player.
The problem arises when the player tries to use an item that allows them to redistribute points. This item makes a call to the server to reset the stats to their initial values (which are random for each monster). The call to reset works perfectly, but the read, using ReadStorageObjectsAsync
, returns an empty array, even though the same call is made for the point distribution.
I am using client version 3.9.0 and backend version 3.16.0
- Code used to make the ReadStorageObjectsAsync call
private async UniTask<IEnumerable<MonsterDbo>> LoadMonstersFromDb(string[] monstersIds)
{
List<MonsterDbo> monsters = new List<MonsterDbo>();
const string monstersCollection = "Monsters";
IApiStorageObjects storageObjectList = null;
StorageObjectId[] ids = new StorageObjectId[monstersIds.Count()];
for (int i = 0; i < monstersIds.Length; i++)
{
ids[i] = new StorageObjectId { Collection = monstersCollection, Key = "nftId-" + monstersIds[i] };
}
try
{
storageObjectList = await _client.ReadStorageObjectsAsync(_session, ids);
}
catch (Exception exception)
{
ErrorResponse(exception.Message);
}
...
}
- Output logs when there is a write, of the stats on the monster.
backend-nakama-1 {"level":"info","ts":"2023-11-09T20:15:11.992Z","caller":"server/runtime_javascript_logger.go:74","msg":"file: main.ts:387 handleBeforeReadStorageObjects"...}
backend-nakama-1 {"level":"info","ts":"2023-11-09T20:15:11.992Z","caller":"server/runtime_javascript_logger.go:74","msg":"file: main.ts:388 ctx map[string]interface {}{\"..."}
backend-nakama-1 {"level":"info","ts":"2023-11-09T20:15:11.992Z","caller":"server/runtime_javascript_logger.go:74","msg":"file: main.ts:389 data map[string]interface {}{\"objectIds\":[]interface {}{map[string]interface {}{\"collection\":\"Monsters\", \"key\":\"nftId-2901\"}}}"...}
backend-nakama-1 {"level":"info","ts":"2023-11-09T20:15:11.992Z","caller":"server/runtime_javascript_logger.go:74","msg":"file: main.ts:390 handleBeforeReadStorageObjects FINISHED"...}
backend-nakama-1 {"level":"info","ts":"2023-11-09T20:15:11.993Z","caller":"server/runtime_javascript_logger.go:74","msg":"file: main.ts:402 handleAfterReadStorageObjects"...}
backend-nakama-1 {"level":"info","ts":"2023-11-09T20:15:11.993Z","caller":"server/runtime_javascript_logger.go:74","msg":"file: main.ts:403 ctx map[string]interface {}{\"..."}
backend-nakama-1 {"level":"info","ts":"2023-11-09T20:15:11.993Z","caller":"server/runtime_javascript_logger.go:74","msg":"file: main.ts:404 data map[string]interface {}{\"objects\":[]interface {}{map[string]interface {}{\"collection\":\"Monsters\", \"createTime\":\"2023-06-20T11:51:56Z\", \"key\":\"nftId-2901\", \"permissionRead\":2, \"updateTime\":\"2023-11-09T20:15:11Z\", \"userId\":\"00000000-0000-0000-0000-000000000000\",...}
backend-nakama-1 {"level":"info","ts":"2023-11-09T20:15:11.993Z","caller":"server/runtime_javascript_logger.go:74","msg":"file: main.ts:405 request map[string]interface {}{\"objectIds\":[]interface {}{map[string]interface {}{\"collection\":\"Monsters\", \"key\":\"nftId-2901\"}}}"...}
backend-nakama-1 {"level":"info","ts":"2023-11-09T20:15:11.993Z","caller":"server/runtime_javascript_logger.go:74","msg":"file: main.ts:406 handleAfterReadStorageObjects FINISHED"...}
- Output logs when there is a read, when the error occurs.
backend-nakama-1 {"level":"info","ts":"2023-11-09T20:44:43.685Z","caller":"server/runtime_javascript_logger.go:74","msg":"file: main.ts:387 handleBeforeReadStorageObjects"...}
backend-nakama-1 {"level":"info","ts":"2023-11-09T20:44:43.685Z","caller":"server/runtime_javascript_logger.go:74","msg":"file: main.ts:388 ctx map[string]interface {}{\"..."
backend-nakama-1 {"level":"info","ts":"2023-11-09T20:44:43.685Z","caller":"server/runtime_javascript_logger.go:74","msg":"file: main.ts:389 data map[string]interface {}{\"objectIds\":[]interface {}{map[string]interface {}{\"collection\":\"Monsters\", \"key\":\"nftId-2901\"}}}"...}
backend-nakama-1 {"level":"info","ts":"2023-11-09T20:44:43.685Z","caller":"server/runtime_javascript_logger.go:74","msg":"file: main.ts:390 handleBeforeReadStorageObjects FINISHED"...}
backend-nakama-1 {"level":"info","ts":"2023-11-09T20:44:43.685Z","caller":"server/runtime_javascript_logger.go:74","msg":"file: main.ts:402 handleAfterReadStorageObjects"...}
backend-nakama-1 {"level":"info","ts":"2023-11-09T20:44:43.685Z","caller":"server/runtime_javascript_logger.go:74","msg":"file: main.ts:403 ctx map[string]interface {}{\"..."}
backend-nakama-1 {"level":"info","ts":"2023-11-09T20:44:43.685Z","caller":"server/runtime_javascript_logger.go:74","msg":"file: main.ts:404 data map[string]interface {}{}","api_id":"readstorageobjects","mode":"after"}
backend-nakama-1 {"level":"info","ts":"2023-11-09T20:44:43.685Z","caller":"server/runtime_javascript_logger.go:74","msg":"file: main.ts:405 request map[string]interface {}{\"objectIds\":[]interface {}{map[string]interface {}{\"collection\":\"Monsters\", \"key\":\"nftId-2901\"}}}"...}
backend-nakama-1 {"level":"info","ts":"2023-11-09T20:44:43.685Z","caller":"server/runtime_javascript_logger.go:74","msg":"file: main.ts:406 handleAfterReadStorageObjects FINISHED"...}