객체에는 객체를 작성하거나 업데이트할 때 해당 객체의 소유자에게 적용되는 권한이 있습니다:
ReadPermission 의 경우 Public Read (2), Owner Read (1) 또는 No Read (0)입니다.
WritePermission 의 경우 Owner Write (1) 또는 No Write (0)입니다.
이러한 권한은 서버가 권한이 있고 항상 객체를 읽고 쓸 수 있으므로 코드 런타임을 통해 저장소 엔진과 상호 작용할 때 무시됩니다. 따라서 No Read / No Write 권한은 클라이언트가 객체를 읽고 쓸 수 없음을 의미합니다.
Owner Read 및 Owner Write 권한이 있는 객체는 이 객체를 소유한 사용자만 액세스하거나 수정할 수 있습니다. 다른 클라이언트는 이 객체에 액세스할 수 없습니다.
Public Read 모든 사용자가 해당 객체를 읽을 수 있음을 의미합니다. 이것은 사용자가 자신의 게임 상태 또는 그 일부를 다른 사용자와 공유해야 하는 게임 플레이의 경우 매우 유용합니다. 예를 들어 서로 싸우고 싶어하는 고유한 "Army" 객체를 가진 사용자가 있을 수 있습니다. 각 사용자는 공개 읽기로 자신의 객체를 작성할 수 있고 다른 사용자가 읽을 수 있으므로 서로의 장치에서 렌더링이 가능합니다.
클라이언트에서 객체를 수정할 때 객체의 기본 권한은 Owner Read 및 Owner Write(으)로 설정됩니다.
코드 런타임에서 객체를 수정할 때 객체의 기본 권한은 No Read 및 No Write(으)로 설정됩니다.
객체를 나열할 때 적절한 권한이 있는 객체만 다시 가져옵니다.
Client
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# "2" refers to Public Read permission# "1" refers to Owner Write permissioncurl -X PUT "http://127.0.0.1:7350/v2/storage"\
-H 'Authorization: Bearer <session token>'\
-d '{
"objects": [
{
"collection": "battle",
"key": "army",
"value": "{"soldiers": 50}",
"permission_read": 2,
"permission_write": 1
}
]
}'
Client
1
2
3
4
5
6
7
8
9
10
11
12
13
14
vararmy_setup={"soldiers":50};// "2" refers to Public Read permission
// "1" refers to Owner Write permission
constobject_ids=awaitclient.writeStorageObjects(session,[{"collection":"saves","key":"savegame","value":army_setup,"permission_read":2,"permission_write":1}]);console.info("Stored objects: %o",object_ids);
Client
1
2
3
4
5
6
7
8
9
10
11
12
13
vararmySetup="{ "soldiers": 50 }";// "2" refers to Public Read permission// "1" refers to Owner Write permissionvarresult=awaitclient.WriteStorageObjectsAsync(session,newWriteStorageObject{Collection="saves",Key="savegame",Value=armySetup,PermissionRead=2,PermissionWrite=1});Console.WriteLine("Stored objects: [{0}]",string.Join(",\n ",result.Objects));
Code snippet for this language TypeScript has not been found. Please choose another language to show equivalent examples.
Server
1
2
3
4
5
6
7
localuser_id="4ec4f126-3f9d-11e7-84ef-b7c182b36521"-- Some user ID.localnew_objects={{collection="battle",key="army",user_id=user_id,value={},permission_read=2,permission_write=1}}nk.storage_write(new_objects)
Server
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
userID:="4ec4f126-3f9d-11e7-84ef-b7c182b36521"// Some user ID.
objects:=[]*runtime.StorageWrite{&runtime.StorageWrite{Collection:"battle",Key:"army",UserID:userID,Value:"{}",PermissionRead:2,PermissionWrite:1,},}if_,err:=nk.StorageWrite(ctx,objects);err!=nil{// Handle error.
}