Version:
DarkMatter 4.1.0
Dependencies:
- Unity : 5.6.X
Overview:
- The User Service is meant to manage all user data for the application. This includes the local users data as well as any remote users who’s data is required by the game.
- The Service defines all of the games bankroll and storage data in the “userService” node of the manifest. This means that for the service to work correctly the Game Service must be initialized and a manifest fetched
- Any operation that could require an asynchronous operation will return a promise that will resolve when complete.
-
The service is broken into several subsystems for managing player profiles and configuration data.
UserService:
- Base service that manages initialization and local user authentication.
UserServiceProfile:
- The container for all a users game server data.
UserServiceProfileManager:
- Managers the player profiles for all the users that have been fetched from the server.
UserServiceDataModel:
- Stores the manifest configuration properties for all the storage items and fetch configurations.
UserServiceItem:
-
The data that is saved in a users profile. Currently there are two supported types
UserServiceBankItem
- A container for an integer based item
UserServiceStorageItem
- A container for object storage.
- The object is stored as a raw json object so the high level structure is required to be in the form of Dictionary<string, object>
Manifest Node Structure see here
Initialization:
- The service requires the use of the hive dependency queue for initialization and must be initialized after the GameService library. This should be handled automatically in the pre setup initialization node included with the package.
- When initializing the service will automatically fetch the local players user data items corresponding with the fetch queue item “onLoad”.
- You can access the local players profile from the profile manager getLocalUserData()
Getting / Setting user profiles:
- You can get users UserServiceProfile from the UserServiceProfileManager with their game service Id.
- When getting a users profile from the profile manager you can set ask the library to attempt to fetch the profile and it’s data if it’s not currently loaded.
- If you’d like to load multiple profiles you can provide a list of user Id’s and it will attempt to fetch data for all the id’s provided.
- Only the local users profile can be saved. If you’ve loaded another players profile and attempt to save the profile this will result in an error.
Fetch configurations
- The fetch configurations are setup so that you can control what data gets uploaded / downloaded for a user and when.
- When getting users data you can provide a fetch configuration key. This key will be used to download only the information required for the current request.
-
An example would be if you need to display a user profiles, but you don’t need their bank or match data. In this case rather then download all the users data, a fetch configuration can be setup that only downloads the profile information. See the manifest “profile” configuration in the manifest node example.
Bank Data:
- One special case is bank information as it is stored and fetched as a single operation. The special key “bank” should be used in the fetch configuration to indicate you’d like to fetch a users bank information and this will fetch all bank data in a single operation.
Special Keys:
- There are a couple fetch configurations that will automatically be used in some instances:
- “onLoad” - fetched when the application loads
- “onConflict” - fetched for both user profiles when there is account conflict while logging into Facebook