This project is a basic test setup of the Multiplay by Rocket Science SDK. Follow the instructions below to complete setup and how to use the SDK
How to install Multiplay by Rocket Science Game Server Local Proxy API (sdkdaemon / payloadproxy) into your Unity project
Window > Package Manager
In the Package Manager Click on the "+" sign in the top left corner then select
"Install Package From Git URL" then paste in https://github.com/rocketsciencegg/multiplay-by-rocket-science-unity-sdk.git
This will install the SDK from the Git URL
The Rocket science CSharp generator produces a Configuration class with the following parameters:
| Name | Type | Description |
|---|---|---|
| basePath | string | The base service path which is overridable. Should be set to a valid URL. |
| requestTimeout | int? | Request timeout for requests in seconds. |
| numRetries | int? | Number of retries for requests. |
| headers | IDictionary<string, string> | Additional headers to add to the request. |
Configuration can be set on three levels: global, api, and request.
Global configuration is created automatically. The generated global configuration is:
| Param | Value |
|---|---|
| basePath | "http://localhost" |
| requestTimeout | 10 |
| numRetries | 4 |
| headers | null |
It can be set and accessed from the service object.
Configuration can be set for specific APIs within a package. To set an API-level Configuration, pass it into the constructor:
public ApiNameClient(IHttpClient httpClient,
IAccessToken accessToken,
Configuration configuration = null)
When set, the configuration will be merged with the global configuration as follows:
| Param | Merge or Override? |
|---|---|
| basePath | Overrides global configuration. |
| requestTimeout | Overrides global configuration. |
| numRetries | Overrides global configuration. |
| headers | Overrides headers also defined in the global configuration, then merges list of unique headers. |
Configuration can also be set per-request. To use a unique configuration for a request, pass it into the request as follows:
public async Task<ResponseReturnType> OperationIdAsync
(OperationIdRequest request, Configuration requestConfiguration)
It will be merged as follows:
| Param | Merge or Override? |
|---|---|
| basePath | Overrides global and api configuration. |
| requestTimeout | Overrides global and api configuration. |
| numRetries | Overrides global and api configuration. |
| headers | Overrides headers also defined in the global or api configuration, then merges list of unique headers in all three. |
The Rocket Science CSharp generator supports the keyword OneOf.
When a OneOf schema is used, it will generate a class of type IOneOf, with a Type and an object.
To use the result, cast the object to the given Type.
Example where CheckedBag is the actual type, and PassengerLuggage is the IOneOf type:
PassengerLuggage response = await _flightsApiClient.GetPassengerLuggageAsync(request);
if (response.Result.Type == typeof(CheckedBag)
{
CheckedBag result = (CheckedBag) response.Result.Value;
}This behavior also extends to errors/exceptions e.g.
try
{
PassengerLuggage response = await _flightsApiClient.GetPassengerLuggageAsync(request);
}
catch(HttpException<LuggageTooHeavy> e)
{
// handle heavyluggage error
}
catch(HttpException<RateLimitError> e)
{
// handle rate limit error
}You will need to initialize the Core package in your code before using the generated code. (Instructions below.)