Navigation
API > API/Plugins > API/Plugins/ConcertSyncClient
References
| Module | ConcertSyncClient |
| Header | /Engine/Plugins/Developer/Concert/ConcertSync/ConcertSyncClient/Source/ConcertSyncClient/Public/IConcertClientDataStore.h |
| Include | #include "IConcertClientDataStore.h" |
ENUM_CLASS_FLAGS
(
EConcertDataStoreChangeNotificationOptions
)
Remarks
Interacts with a key/value store shared by one or more clients connected to a Concert session. The store is like a TMap
The store is type safe, in the sense that a client cannot transmute the type of a stored value into another type. For example if the value "foo" is an integer, it cannot be transformed into a double later one.
The store is used to share variables with other clients. For example, it can be used for to manage a distributed counter like "cameraId" to uniquely number cameras created concurrently by multiple users while editing a level.
The store API returns TFuture to implement asynchronous or blocking operations. While is far more easier to use the blocking operations model, i.e. waiting on future to gets its result (TFuture::Get()) in the caller thread, it is recommended to use the asynchronous API and use continuations. Since the store implies network operation, expect latency and avoid waiting the response in a thread like the game thread.
To implement a sequence of operations using the store asynchronously inside a single thread (game thread), it is recommended to implement it as a finite state machine 'ticked' at each loop.
Example: Initialize a shared value. The code snippet below shows how multiple clients can concurrently create or sync a shared integer value to be ready to compare exchange it later to generate a new unique id.
voidMyClass::InitCameraIdAsync(){FNameKey(TEXT("CameraId"));//Thesharedvariablename.int64Value=0;//Theinitialvalueifnotexistingyet.//Trytofetchthespecifiedkeyvalue(abasictype),ifthekeydoesn'texist,additwiththespecifiedvalue.GetDataStore().FetchOrAdd(Key,Value).Next(this,Key,Value{//Ifthekeywasaddedorfetched.if(Result){CameraId=Result.GetValue();bCameraIdAcquired=true;}else{//Thekeyalreadyexisted,butthevaluewasnotaint64.check(Response.GetCode()==EConcertDataStoreResultCode::TypeMismatch);}});
Example: Use custom types. The code snippet below shows how a user can use a custom type with the data store. For simplicity, the example block until the result is available and assumes the all operations succeeded.
USTRUCT()structFPoint2D{int32x;int32y;};USTRUCT()structFShape{TArray