Game Service 4.0.0
Beta Features:
- Facebook login / logout
Dependencies:
- Unity : 5.6.X
- DarkMatter : 4.0.0
Overview:
-
The Game Service library is meant to manage communication with the Magmic remote v5 Game Service. It manages server configurations, user authentication, Facebook login / logout and manifests.
-
The service uses a GameServiceConfiguration to define how it should communicate with the v5 server. A default configuration is required to be passed in when initializing, other configurations should be defined in the “gameService” node of the manifest.
-
For more details on a GameServiceConfiguration see further documentation GameServiceConfiguration gameId : string - The magmic game id, this will be used as part of the request to get a games manifest.
url : string - The base address to connect to the server
secret : string - used to sign requests
key : string - will be used by the server to map the request to the game
numberOfRetries : List
- An array of numeric string object that define how the service will retry failed requests. - The number of objects is how many times it will retry and the numeric value of the string is how long it will delay before retrying the request
Example Manifest Node:
"gameService": {
"activeConfigurationKey": "qa",
"configurations": {
"qa": {
"gameId": "du7u0g26q1dixcmw2n2qsk968qktksj8",
"url": "http://v5-api-staging.magmic.com",
"secret": "MCSV5TEST4PP0ead5c63c35d902f9f561702ecf588c02d038224d15e901270a0b566951f77f",
"key": "MCSV5TEST4PPab9c0ea7ca19b39bccbe15b8",
"numberOfRetries": [
"0.5",
"1.0",
"3.0"
]
},
"localhost": {
"gameId": "du7u0g26q1dixcmw2n2qsk968qktksj8",
"url": "http://localhost:3000",
"secret": "MCSV5TEST4PP0ead5c63c35d902f9f561702ecf588c02d038224d15e901270a0b566951f77f",
"key": "MCSV5TEST4PPab9c0ea7ca19b39bccbe15b8",
"numberOfRetries": [
"0.5",
"1.0",
"3.0"
]
},
"prod": {
"gameId": "pfjdm4uh7r0vw754dz07oj7qeyy0tn80",
"url": "https://v5-api.gameserver.magmic.com",
"secret": "374ce8c653aacc4adac683d4c0a2adc73d6dc1b63125172352507ad249663ed4",
"key": "MCSV507210c92fe151bdb4f468436499747b",
"numberOfRetries": [
"0.5",
"1.0",
"3.0"
]
}
}
- When initializing the service it will used the default GameServiceConfiguration passed in until it has successfully connected and received an updated manifest. Once the serviced has a manifest all subsequent calls will be made using the active configuration set in the manifest. If the configuration in the manifest has changed the service will reinitialize it’s connecting to game service using the new configuration set in the manifest. As a safety precaution if this new manifest changes the configuration again initialization will fail to prevent a configuration loop.
- Initialization example
GameService.Instance.Initialize(default Configuration) .Catch(initError => { // Handle error // NOTE - All errors thrown by game service will come back as Exceptions, but can be cast as DarkMatterErrors to get more information or data associated with the error. DarkMatterError error = initError as DarkMatterError; }) .Done(rsp => { //Initialization complete successfully, the user has identified and will have an updated manifest }); -
Once initialized the user will have been assigned a user id and token that will be used to identify them in later calls. This information will be stored an managed by the Service so that application is not required to manage this data.
-
Manifests are tightly coupled to individual users, so any change in the users authentication state could change their underlying manifest. This should all be managed under discreetly by the Game Service.
- After a successful initialization, future calls will log the user back in as the same user.