当前提交
7613f693
共有 131 个文件被更改,包括 4347 次插入 和 0 次删除
-
19LocalPackage/com.unity.services.lobby/.npmignore
-
11LocalPackage/com.unity.services.lobby/CHANGELOG.md
-
7LocalPackage/com.unity.services.lobby/CHANGELOG.md.meta
-
9LocalPackage/com.unity.services.lobby/CONTRIBUTING.md
-
7LocalPackage/com.unity.services.lobby/CONTRIBUTING.md.meta
-
41LocalPackage/com.unity.services.lobby/Documentation~/com.unity.services.lobby.md
-
5LocalPackage/com.unity.services.lobby/LICENSE.md
-
7LocalPackage/com.unity.services.lobby/LICENSE.md.meta
-
26LocalPackage/com.unity.services.lobby/QAReport.md
-
7LocalPackage/com.unity.services.lobby/QAReport.md.meta
-
47LocalPackage/com.unity.services.lobby/README.md
-
7LocalPackage/com.unity.services.lobby/README.md.meta
-
8LocalPackage/com.unity.services.lobby/Runtime.meta
-
8LocalPackage/com.unity.services.lobby/Runtime/Apis.meta
-
313LocalPackage/com.unity.services.lobby/Runtime/Apis/LobbyApi.cs
-
11LocalPackage/com.unity.services.lobby/Runtime/Apis/LobbyApi.cs.meta
-
975LocalPackage/com.unity.services.lobby/Runtime/Apis/LobbyApiRequests.cs
-
11LocalPackage/com.unity.services.lobby/Runtime/Apis/LobbyApiRequests.cs.meta
-
8LocalPackage/com.unity.services.lobby/Runtime/Configuration.meta
-
69LocalPackage/com.unity.services.lobby/Runtime/Configuration/Configuration.cs
-
11LocalPackage/com.unity.services.lobby/Runtime/Configuration/Configuration.cs.meta
-
8LocalPackage/com.unity.services.lobby/Runtime/Http.meta
-
109LocalPackage/com.unity.services.lobby/Runtime/Http/AsyncOpRetry.cs
-
11LocalPackage/com.unity.services.lobby/Runtime/Http/AsyncOpRetry.cs.meta
-
15LocalPackage/com.unity.services.lobby/Runtime/Http/BaseApiClient.cs
-
11LocalPackage/com.unity.services.lobby/Runtime/Http/BaseApiClient.cs.meta
-
35LocalPackage/com.unity.services.lobby/Runtime/Http/BasicError.cs
-
11LocalPackage/com.unity.services.lobby/Runtime/Http/BasicError.cs.meta
-
35LocalPackage/com.unity.services.lobby/Runtime/Http/CommonErrors.cs
-
11LocalPackage/com.unity.services.lobby/Runtime/Http/CommonErrors.cs.meta
-
34LocalPackage/com.unity.services.lobby/Runtime/Http/DeserializationException.cs
-
11LocalPackage/com.unity.services.lobby/Runtime/Http/DeserializationException.cs.meta
-
239LocalPackage/com.unity.services.lobby/Runtime/Http/HttpClient.cs
-
11LocalPackage/com.unity.services.lobby/Runtime/Http/HttpClient.cs.meta
-
26LocalPackage/com.unity.services.lobby/Runtime/Http/HttpClientResponse.cs
-
11LocalPackage/com.unity.services.lobby/Runtime/Http/HttpClientResponse.cs.meta
-
51LocalPackage/com.unity.services.lobby/Runtime/Http/HttpException.cs
-
11LocalPackage/com.unity.services.lobby/Runtime/Http/HttpException.cs.meta
-
11LocalPackage/com.unity.services.lobby/Runtime/Http/IError.cs
-
11LocalPackage/com.unity.services.lobby/Runtime/Http/IError.cs.meta
-
18LocalPackage/com.unity.services.lobby/Runtime/Http/IHttpClient.cs
-
11LocalPackage/com.unity.services.lobby/Runtime/Http/IHttpClient.cs.meta
-
32LocalPackage/com.unity.services.lobby/Runtime/Http/JsonHelpers.cs
-
11LocalPackage/com.unity.services.lobby/Runtime/Http/JsonHelpers.cs.meta
-
168LocalPackage/com.unity.services.lobby/Runtime/Http/ResponseHandler.cs
-
11LocalPackage/com.unity.services.lobby/Runtime/Http/ResponseHandler.cs.meta
-
27LocalPackage/com.unity.services.lobby/Runtime/Http/Responses.cs
-
11LocalPackage/com.unity.services.lobby/Runtime/Http/Responses.cs.meta
-
39LocalPackage/com.unity.services.lobby/Runtime/Http/UnityWebRequestHelpers.cs
-
11LocalPackage/com.unity.services.lobby/Runtime/Http/UnityWebRequestHelpers.cs.meta
-
15LocalPackage/com.unity.services.lobby/Runtime/LobbyService.cs
-
11LocalPackage/com.unity.services.lobby/Runtime/LobbyService.cs.meta
-
45LocalPackage/com.unity.services.lobby/Runtime/LobbyServiceProvider.cs
-
11LocalPackage/com.unity.services.lobby/Runtime/LobbyServiceProvider.cs.meta
-
8LocalPackage/com.unity.services.lobby/Runtime/Models.meta
-
74LocalPackage/com.unity.services.lobby/Runtime/Models/CreateRequest.cs
-
11LocalPackage/com.unity.services.lobby/Runtime/Models/CreateRequest.cs.meta
-
155LocalPackage/com.unity.services.lobby/Runtime/Models/DataObject.cs
-
11LocalPackage/com.unity.services.lobby/Runtime/Models/DataObject.cs.meta
-
47LocalPackage/com.unity.services.lobby/Runtime/Models/Detail.cs
-
11LocalPackage/com.unity.services.lobby/Runtime/Models/Detail.cs.meta
-
56LocalPackage/com.unity.services.lobby/Runtime/Models/ErrorStatus.cs
-
11LocalPackage/com.unity.services.lobby/Runtime/Models/ErrorStatus.cs.meta
-
47LocalPackage/com.unity.services.lobby/Runtime/Models/JoinByCodeRequest.cs
-
11LocalPackage/com.unity.services.lobby/Runtime/Models/JoinByCodeRequest.cs.meta
-
56LocalPackage/com.unity.services.lobby/Runtime/Models/JoinRequest.cs
-
11LocalPackage/com.unity.services.lobby/Runtime/Models/JoinRequest.cs.meta
-
31LocalPackage/com.unity.services.lobby/Runtime/Models/JoinRequestOneOf.cs
-
11LocalPackage/com.unity.services.lobby/Runtime/Models/JoinRequestOneOf.cs.meta
-
137LocalPackage/com.unity.services.lobby/Runtime/Models/Lobby.cs
-
11LocalPackage/com.unity.services.lobby/Runtime/Models/Lobby.cs.meta
-
10LocalPackage/com.unity.services.lobby/Runtime/Models/LobbyIOneOf.cs
-
11LocalPackage/com.unity.services.lobby/Runtime/Models/LobbyIOneOf.cs.meta
-
83LocalPackage/com.unity.services.lobby/Runtime/Models/Player.cs
-
11LocalPackage/com.unity.services.lobby/Runtime/Models/Player.cs.meta
-
76LocalPackage/com.unity.services.lobby/Runtime/Models/PlayerDataObject.cs
-
11LocalPackage/com.unity.services.lobby/Runtime/Models/PlayerDataObject.cs.meta
-
56LocalPackage/com.unity.services.lobby/Runtime/Models/PlayerUpdateRequest.cs
-
11LocalPackage/com.unity.services.lobby/Runtime/Models/PlayerUpdateRequest.cs.meta
-
210LocalPackage/com.unity.services.lobby/Runtime/Models/QueryFilter.cs
-
11LocalPackage/com.unity.services.lobby/Runtime/Models/QueryFilter.cs.meta
-
154LocalPackage/com.unity.services.lobby/Runtime/Models/QueryOrder.cs
-
11LocalPackage/com.unity.services.lobby/Runtime/Models/QueryOrder.cs.meta
-
83LocalPackage/com.unity.services.lobby/Runtime/Models/QueryRequest.cs
-
11LocalPackage/com.unity.services.lobby/Runtime/Models/QueryRequest.cs.meta
-
47LocalPackage/com.unity.services.lobby/Runtime/Models/QueryResponse.cs
-
11LocalPackage/com.unity.services.lobby/Runtime/Models/QueryResponse.cs.meta
-
47LocalPackage/com.unity.services.lobby/Runtime/Models/QuickJoinRequest.cs
-
11LocalPackage/com.unity.services.lobby/Runtime/Models/QuickJoinRequest.cs.meta
-
74LocalPackage/com.unity.services.lobby/Runtime/Models/UpdateRequest.cs
-
11LocalPackage/com.unity.services.lobby/Runtime/Models/UpdateRequest.cs.meta
-
8LocalPackage/com.unity.services.lobby/Runtime/Scheduler.meta
|
|||
artifacts/** |
|||
build/** |
|||
.build_script/** |
|||
node_modules/** |
|||
Documentation/ApiDocs/** |
|||
Documentation~/ApiDocs/** |
|||
.DS_Store |
|||
.npmrc |
|||
.npmignore |
|||
.gitignore |
|||
CONTRIBUTING.md |
|||
CONTRIBUTING.md.meta |
|||
QAReport.md |
|||
QAReport.md.meta |
|||
.gitlab-ci.yml |
|||
build.sh |
|||
build.sh.meta |
|||
build.bat |
|||
build.bat.meta |
|
|||
# Changelog |
|||
All notable changes to this package will be documented in this file. |
|||
|
|||
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) |
|||
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). |
|||
|
|||
## [0.2.0] - 2021-07-06 |
|||
|
|||
### This is the first release of *Unity Package Lobby*. |
|||
|
|||
This package implements the client API for the Unity Lobby service. |
|
|||
fileFormatVersion: 2 |
|||
guid: 06d40308e46a74978beb69ddb7ae0d7b |
|||
TextScriptImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
# Contributing |
|||
|
|||
## If you are interested in contributing, here are some ground rules: |
|||
* ... Define guidelines & rules for what contributors need to know to successfully make Pull requests against your repo ... |
|||
|
|||
## All contributions are subject to the [Unity Contribution Agreement(UCA)](https://unity3d.com/legal/licenses/Unity_Contribution_Agreement) |
|||
By making a pull request, you are confirming agreement to the terms and conditions of the UCA, including that your Contributions are your original creation and that you have complete right and authority to make your Contributions. |
|||
|
|||
## Once you have a change ready following these ground rules. Simply make a pull request |
|
|||
fileFormatVersion: 2 |
|||
guid: d997183ab5f3e4f1aabd60a9e9d99360 |
|||
TextScriptImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
# Documentation for Unity Lobby |
|||
<a name="documentation-for-api-endpoints"></a> |
|||
## Documentation for API Endpoints |
|||
All URIs are relative to *https://lobby.cloud.unity3d.com/v1* |
|||
Class | Method | HTTP request | Description |
|||
------------ | ------------- | ------------- | ------------- |
|||
*LobbyApi* | [**CreateLobby**](Apis/LobbyApi.md#createlobby) | **POST** /create | Create a lobby |
|||
*LobbyApi* | [**DeleteLobby**](Apis/LobbyApi.md#deletelobby) | **DELETE** /{lobbyId} | Delete a lobby |
|||
*LobbyApi* | [**GetLobby**](Apis/LobbyApi.md#getlobby) | **GET** /{lobbyId} | Get lobby details |
|||
*LobbyApi* | [**JoinLobbyByCode**](Apis/LobbyApi.md#joinlobbybycode) | **POST** /joinbycode | Join a lobby with lobby code |
|||
*LobbyApi* | [**JoinLobbyById**](Apis/LobbyApi.md#joinlobbybyid) | **POST** /{lobbyId}/join | Join a lobby with lobby ID |
|||
*LobbyApi* | [**QueryLobbies**](Apis/LobbyApi.md#querylobbies) | **POST** /query | Query public lobbies |
|||
*LobbyApi* | [**QuickJoinLobby**](Apis/LobbyApi.md#quickjoinlobby) | **POST** /quickjoin | Query available lobbies and join a random one |
|||
*LobbyApi* | [**RemovePlayer**](Apis/LobbyApi.md#removeplayer) | **DELETE** /{lobbyId}/players/{playerId} | Remove a player |
|||
*LobbyApi* | [**UpdateLobby**](Apis/LobbyApi.md#updatelobby) | **POST** /{lobbyId} | Update lobby data |
|||
*LobbyApi* | [**UpdatePlayer**](Apis/LobbyApi.md#updateplayer) | **POST** /{lobbyId}/players/{playerId} | Update player data |
|||
|
|||
<a name="documentation-for-models"></a> |
|||
## Documentation for Models |
|||
- [Models.CreateRequest](Models/CreateRequest.md) |
|||
- [Models.DataObject](Models/DataObject.md) |
|||
- [Models.Detail](Models/Detail.md) |
|||
- [Models.ErrorStatus](Models/ErrorStatus.md) |
|||
- [Models.JoinByCodeRequest](Models/JoinByCodeRequest.md) |
|||
- [Models.Lobby](Models/Lobby.md) |
|||
- [Models.Player](Models/Player.md) |
|||
- [Models.PlayerDataObject](Models/PlayerDataObject.md) |
|||
- [Models.PlayerUpdateRequest](Models/PlayerUpdateRequest.md) |
|||
- [Models.QueryFilter](Models/QueryFilter.md) |
|||
- [Models.QueryOrder](Models/QueryOrder.md) |
|||
- [Models.QueryRequest](Models/QueryRequest.md) |
|||
- [Models.QueryResponse](Models/QueryResponse.md) |
|||
- [Models.QuickJoinRequest](Models/QuickJoinRequest.md) |
|||
- [Models.UpdateRequest](Models/UpdateRequest.md) |
|||
|
|||
<a name="documentation-for-authorization"></a> |
|||
## Documentation for Authorization |
|||
<a name="JWT"></a> |
|||
### JWT |
|||
- **Type**: HTTP basic authentication |
|||
|
|
|||
com.unity.services.lobby copyright © 2021 Unity Technologies |
|||
|
|||
This software is subject to, and made available under, the terms of service for Unity Lobby (see [Operate Terms of Service](https://unity3d.com/legal/one-operate-services-terms-of-service)). |
|||
|
|||
Unless expressly provided otherwise, the software under this license is made available strictly on an "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED. Please review the terms of service for details on these and other terms and conditions. |
|
|||
fileFormatVersion: 2 |
|||
guid: 9a250b1c14b734726aa1f1cfa2c88464 |
|||
TextScriptImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
# Quality Report |
|||
Use this file to outline the test strategy for this package. |
|||
|
|||
## Version tested: [*package version*] |
|||
|
|||
## QA Owner: [*Add Name*] |
|||
## UX Owner: [*Add Name*] |
|||
|
|||
## Test strategy |
|||
*Use this section to describe how this feature was tested.* |
|||
* A link to the Test Plan (Test Rails, other) |
|||
* Results from the package's editor and runtime test suite. |
|||
* Link to automated test results (if any) |
|||
* Manual test Results, [here's an example](https://docs.google.com/spreadsheets/d/12A76U5Gf969w10KL4Ik0wC1oFIBDUoRrqIvQgD18TFo/edit#gid=0) |
|||
* Scenario test week outcome |
|||
* etc. |
|||
|
|||
## Package Status |
|||
Use this section to describe: |
|||
* UX status/evaluation results |
|||
* package stability |
|||
* known bugs, issues |
|||
* performance metrics, |
|||
* etc |
|||
|
|||
In other words, a general feeling on the health of this package. |
|
|||
fileFormatVersion: 2 |
|||
guid: 97fcfa49be10541dd90e14f614c43925 |
|||
TextScriptImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
# Unity Lobby |
|||
|
|||
## Installing Unity Lobby |
|||
|
|||
1. Launch Unity |
|||
2. Window > Package Manager |
|||
3. In the Package Manager Click on the "+" sign in the top left corner then select "Add Package From Disk" then browse to |
|||
`com.unity.services.lobby` and select package.json > open |
|||
|
|||
## Unity Authentication Requirement |
|||
|
|||
The Unity Lobby service requires Unity authentication. To use it, install the `com.unity.services.authentication` package. |
|||
|
|||
### Using Unity Authentication |
|||
|
|||
To use authentication, you will need to import the package: |
|||
|
|||
```csharp |
|||
using Unity.Services.Authentication; |
|||
``` |
|||
|
|||
Once imported, you will need to log in before using API calls. |
|||
|
|||
Sample Usage: |
|||
|
|||
```csharp |
|||
async void Start() |
|||
{ |
|||
await UnityServices.Initialize(); |
|||
await AuthenticationService.Instance.SignInAnonymouslyAsync(); |
|||
if (AuthenticationService.Instance.IsSignedIn) |
|||
{ |
|||
MakeAPICall(); |
|||
} |
|||
else |
|||
{ |
|||
Debug.Log("Player was not signed in successfully?"); |
|||
} |
|||
|
|||
} |
|||
|
|||
async void MakeAPICall() |
|||
{ |
|||
FakeApiGetRequest r = new FakeApiGetRequest("fakeParameter"); |
|||
var response = await LobbyApiService.FakeClient.FakeApiGetAsync(r); |
|||
} |
|||
``` |
|
|||
fileFormatVersion: 2 |
|||
guid: 784a1d5bae6a048b4a1ad0b750d23a93 |
|||
TextScriptImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 73245f28b46bd494b8ed4601d27921b2 |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 0281d305333c1488b9b2bc3c4f3c26c5 |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Threading.Tasks; |
|||
using System.Collections.Generic; |
|||
using Unity.Services.Lobbies.Models; |
|||
using Unity.Services.Lobbies.Http; |
|||
using TaskScheduler = Unity.Services.Lobbies.Scheduler.TaskScheduler; |
|||
using Unity.Services.Authentication; |
|||
using Unity.Services.Lobbies; |
|||
|
|||
namespace Unity.Services.Lobbies.Apis |
|||
{ |
|||
public interface ILobbyApiClient |
|||
{ |
|||
/// <summary>
|
|||
/// Async Operation.
|
|||
/// Create a lobby
|
|||
/// </summary>
|
|||
/// <param name="request">Request object for CreateLobby</param>
|
|||
/// <returns>Task for a Response object containing status code, headers, and Lobby object</returns>
|
|||
/// <exception cref="Unity.Services.Lobbies.Http.HttpException">An exception containing the HttpClientResponse with headers, response code, and string of error.</exception>
|
|||
Task<Response<Lobby>> CreateLobbyAsync(CreateLobbyRequest request, Configuration operationConfiguration = null); |
|||
|
|||
/// <summary>
|
|||
/// Async Operation.
|
|||
/// Delete a lobby
|
|||
/// </summary>
|
|||
/// <param name="request">Request object for DeleteLobby</param>
|
|||
/// <returns>Task for a Response object containing status code, headers</returns>
|
|||
/// <exception cref="Unity.Services.Lobbies.Http.HttpException">An exception containing the HttpClientResponse with headers, response code, and string of error.</exception>
|
|||
Task<Response> DeleteLobbyAsync(DeleteLobbyRequest request, Configuration operationConfiguration = null); |
|||
|
|||
/// <summary>
|
|||
/// Async Operation.
|
|||
/// Get lobby details
|
|||
/// </summary>
|
|||
/// <param name="request">Request object for GetLobby</param>
|
|||
/// <returns>Task for a Response object containing status code, headers, and Lobby object</returns>
|
|||
/// <exception cref="Unity.Services.Lobbies.Http.HttpException">An exception containing the HttpClientResponse with headers, response code, and string of error.</exception>
|
|||
Task<Response<Lobby>> GetLobbyAsync(GetLobbyRequest request, Configuration operationConfiguration = null); |
|||
|
|||
/// <summary>
|
|||
/// Async Operation.
|
|||
/// Join a lobby with lobby code
|
|||
/// </summary>
|
|||
/// <param name="request">Request object for JoinLobbyByCode</param>
|
|||
/// <returns>Task for a Response object containing status code, headers, and Lobby object</returns>
|
|||
/// <exception cref="Unity.Services.Lobbies.Http.HttpException">An exception containing the HttpClientResponse with headers, response code, and string of error.</exception>
|
|||
Task<Response<Lobby>> JoinLobbyByCodeAsync(JoinLobbyByCodeRequest request, Configuration operationConfiguration = null); |
|||
|
|||
/// <summary>
|
|||
/// Async Operation.
|
|||
/// Join a lobby with lobby ID
|
|||
/// </summary>
|
|||
/// <param name="request">Request object for JoinLobbyById</param>
|
|||
/// <returns>Task for a Response object containing status code, headers, and Lobby object</returns>
|
|||
/// <exception cref="Unity.Services.Lobbies.Http.HttpException">An exception containing the HttpClientResponse with headers, response code, and string of error.</exception>
|
|||
Task<Response<Lobby>> JoinLobbyByIdAsync(JoinLobbyByIdRequest request, Configuration operationConfiguration = null); |
|||
|
|||
/// <summary>
|
|||
/// Async Operation.
|
|||
/// Query public lobbies
|
|||
/// </summary>
|
|||
/// <param name="request">Request object for QueryLobbies</param>
|
|||
/// <returns>Task for a Response object containing status code, headers, and QueryResponse object</returns>
|
|||
/// <exception cref="Unity.Services.Lobbies.Http.HttpException">An exception containing the HttpClientResponse with headers, response code, and string of error.</exception>
|
|||
Task<Response<QueryResponse>> QueryLobbiesAsync(QueryLobbiesRequest request, Configuration operationConfiguration = null); |
|||
|
|||
/// <summary>
|
|||
/// Async Operation.
|
|||
/// Query available lobbies and join a random one
|
|||
/// </summary>
|
|||
/// <param name="request">Request object for QuickJoinLobby</param>
|
|||
/// <returns>Task for a Response object containing status code, headers, and Lobby object</returns>
|
|||
/// <exception cref="Unity.Services.Lobbies.Http.HttpException">An exception containing the HttpClientResponse with headers, response code, and string of error.</exception>
|
|||
Task<Response<Lobby>> QuickJoinLobbyAsync(QuickJoinLobbyRequest request, Configuration operationConfiguration = null); |
|||
|
|||
/// <summary>
|
|||
/// Async Operation.
|
|||
/// Remove a player
|
|||
/// </summary>
|
|||
/// <param name="request">Request object for RemovePlayer</param>
|
|||
/// <returns>Task for a Response object containing status code, headers</returns>
|
|||
/// <exception cref="Unity.Services.Lobbies.Http.HttpException">An exception containing the HttpClientResponse with headers, response code, and string of error.</exception>
|
|||
Task<Response> RemovePlayerAsync(RemovePlayerRequest request, Configuration operationConfiguration = null); |
|||
|
|||
/// <summary>
|
|||
/// Async Operation.
|
|||
/// Update lobby data
|
|||
/// </summary>
|
|||
/// <param name="request">Request object for UpdateLobby</param>
|
|||
/// <returns>Task for a Response object containing status code, headers, and Lobby object</returns>
|
|||
/// <exception cref="Unity.Services.Lobbies.Http.HttpException">An exception containing the HttpClientResponse with headers, response code, and string of error.</exception>
|
|||
Task<Response<Lobby>> UpdateLobbyAsync(UpdateLobbyRequest request, Configuration operationConfiguration = null); |
|||
|
|||
/// <summary>
|
|||
/// Async Operation.
|
|||
/// Update player data
|
|||
/// </summary>
|
|||
/// <param name="request">Request object for UpdatePlayer</param>
|
|||
/// <returns>Task for a Response object containing status code, headers, and Lobby object</returns>
|
|||
/// <exception cref="Unity.Services.Lobbies.Http.HttpException">An exception containing the HttpClientResponse with headers, response code, and string of error.</exception>
|
|||
Task<Response<Lobby>> UpdatePlayerAsync(UpdatePlayerRequest request, Configuration operationConfiguration = null); |
|||
|
|||
} |
|||
|
|||
///<inheritdoc cref="ILobbyApiClient"/>
|
|||
public class LobbyApiClient : BaseApiClient, ILobbyApiClient |
|||
{ |
|||
private IAccessToken _accessToken; |
|||
private Configuration _configuration; |
|||
public Configuration Configuration |
|||
{ |
|||
get { |
|||
// We return a merge between the current configuration and the
|
|||
// global configuration to ensure we have the correct
|
|||
// combination of headers and a base path (if it is set).
|
|||
return Configuration.MergeConfigurations(_configuration, LobbyService.Configuration); |
|||
} |
|||
} |
|||
|
|||
public LobbyApiClient(IHttpClient httpClient, |
|||
TaskScheduler taskScheduler, |
|||
IAccessToken accessToken, |
|||
Configuration configuration = null) : base(httpClient, taskScheduler) |
|||
{ |
|||
// We don't need to worry about the configuration being null at
|
|||
// this stage, we will check this in the accessor.
|
|||
_configuration = configuration; |
|||
|
|||
_accessToken = accessToken; |
|||
} |
|||
|
|||
public async Task<Response<Lobby>> CreateLobbyAsync(CreateLobbyRequest request, |
|||
Configuration operationConfiguration = null) |
|||
{ |
|||
var statusCodeToTypeMap = new Dictionary<string, System.Type>() { { "201", typeof(Lobby) },{ "400", typeof(ErrorStatus) },{ "403", typeof(ErrorStatus) } }; |
|||
|
|||
// Merge the operation/request level configuration with the client level configuration.
|
|||
var finalConfiguration = Configuration.MergeConfigurations(operationConfiguration, Configuration); |
|||
|
|||
var response = await HttpClient.MakeRequestAsync("POST", |
|||
request.ConstructUrl(finalConfiguration.BasePath), |
|||
request.ConstructBody(), |
|||
request.ConstructHeaders(_accessToken, finalConfiguration), |
|||
finalConfiguration.RequestTimeout); |
|||
|
|||
var handledResponse = ResponseHandler.HandleAsyncResponse<Lobby>(response, statusCodeToTypeMap); |
|||
return new Response<Lobby>(response, handledResponse); |
|||
} |
|||
|
|||
public async Task<Response> DeleteLobbyAsync(DeleteLobbyRequest request, |
|||
Configuration operationConfiguration = null) |
|||
{ |
|||
var statusCodeToTypeMap = new Dictionary<string, System.Type>() { { "204", null },{ "400", typeof(ErrorStatus) },{ "403", typeof(ErrorStatus) },{ "404", typeof(ErrorStatus) } }; |
|||
|
|||
// Merge the operation/request level configuration with the client level configuration.
|
|||
var finalConfiguration = Configuration.MergeConfigurations(operationConfiguration, Configuration); |
|||
|
|||
var response = await HttpClient.MakeRequestAsync("DELETE", |
|||
request.ConstructUrl(finalConfiguration.BasePath), |
|||
request.ConstructBody(), |
|||
request.ConstructHeaders(_accessToken, finalConfiguration), |
|||
finalConfiguration.RequestTimeout); |
|||
|
|||
ResponseHandler.HandleAsyncResponse(response, statusCodeToTypeMap); |
|||
return new Response(response); |
|||
} |
|||
|
|||
public async Task<Response<Lobby>> GetLobbyAsync(GetLobbyRequest request, |
|||
Configuration operationConfiguration = null) |
|||
{ |
|||
var statusCodeToTypeMap = new Dictionary<string, System.Type>() { { "200", typeof(Lobby) },{ "403", typeof(ErrorStatus) },{ "404", typeof(ErrorStatus) } }; |
|||
|
|||
// Merge the operation/request level configuration with the client level configuration.
|
|||
var finalConfiguration = Configuration.MergeConfigurations(operationConfiguration, Configuration); |
|||
|
|||
var response = await HttpClient.MakeRequestAsync("GET", |
|||
request.ConstructUrl(finalConfiguration.BasePath), |
|||
request.ConstructBody(), |
|||
request.ConstructHeaders(_accessToken, finalConfiguration), |
|||
finalConfiguration.RequestTimeout); |
|||
|
|||
var handledResponse = ResponseHandler.HandleAsyncResponse<Lobby>(response, statusCodeToTypeMap); |
|||
return new Response<Lobby>(response, handledResponse); |
|||
} |
|||
|
|||
public async Task<Response<Lobby>> JoinLobbyByCodeAsync(JoinLobbyByCodeRequest request, |
|||
Configuration operationConfiguration = null) |
|||
{ |
|||
var statusCodeToTypeMap = new Dictionary<string, System.Type>() { { "200", typeof(Lobby) },{ "400", typeof(ErrorStatus) },{ "403", typeof(ErrorStatus) },{ "409", typeof(ErrorStatus) } }; |
|||
|
|||
// Merge the operation/request level configuration with the client level configuration.
|
|||
var finalConfiguration = Configuration.MergeConfigurations(operationConfiguration, Configuration); |
|||
|
|||
var response = await HttpClient.MakeRequestAsync("POST", |
|||
request.ConstructUrl(finalConfiguration.BasePath), |
|||
request.ConstructBody(), |
|||
request.ConstructHeaders(_accessToken, finalConfiguration), |
|||
finalConfiguration.RequestTimeout); |
|||
|
|||
var handledResponse = ResponseHandler.HandleAsyncResponse<Lobby>(response, statusCodeToTypeMap); |
|||
return new Response<Lobby>(response, handledResponse); |
|||
} |
|||
|
|||
public async Task<Response<Lobby>> JoinLobbyByIdAsync(JoinLobbyByIdRequest request, |
|||
Configuration operationConfiguration = null) |
|||
{ |
|||
var statusCodeToTypeMap = new Dictionary<string, System.Type>() { { "200", typeof(Lobby) },{ "400", typeof(ErrorStatus) },{ "403", typeof(ErrorStatus) },{ "404", typeof(ErrorStatus) },{ "409", typeof(ErrorStatus) } }; |
|||
|
|||
// Merge the operation/request level configuration with the client level configuration.
|
|||
var finalConfiguration = Configuration.MergeConfigurations(operationConfiguration, Configuration); |
|||
|
|||
var response = await HttpClient.MakeRequestAsync("POST", |
|||
request.ConstructUrl(finalConfiguration.BasePath), |
|||
request.ConstructBody(), |
|||
request.ConstructHeaders(_accessToken, finalConfiguration), |
|||
finalConfiguration.RequestTimeout); |
|||
|
|||
var handledResponse = ResponseHandler.HandleAsyncResponse<Lobby>(response, statusCodeToTypeMap); |
|||
return new Response<Lobby>(response, handledResponse); |
|||
} |
|||
|
|||
public async Task<Response<QueryResponse>> QueryLobbiesAsync(QueryLobbiesRequest request, |
|||
Configuration operationConfiguration = null) |
|||
{ |
|||
var statusCodeToTypeMap = new Dictionary<string, System.Type>() { { "200", typeof(QueryResponse) },{ "400", typeof(ErrorStatus) },{ "403", typeof(ErrorStatus) } }; |
|||
|
|||
// Merge the operation/request level configuration with the client level configuration.
|
|||
var finalConfiguration = Configuration.MergeConfigurations(operationConfiguration, Configuration); |
|||
|
|||
var response = await HttpClient.MakeRequestAsync("POST", |
|||
request.ConstructUrl(finalConfiguration.BasePath), |
|||
request.ConstructBody(), |
|||
request.ConstructHeaders(_accessToken, finalConfiguration), |
|||
finalConfiguration.RequestTimeout); |
|||
|
|||
var handledResponse = ResponseHandler.HandleAsyncResponse<QueryResponse>(response, statusCodeToTypeMap); |
|||
return new Response<QueryResponse>(response, handledResponse); |
|||
} |
|||
|
|||
public async Task<Response<Lobby>> QuickJoinLobbyAsync(QuickJoinLobbyRequest request, |
|||
Configuration operationConfiguration = null) |
|||
{ |
|||
var statusCodeToTypeMap = new Dictionary<string, System.Type>() { { "200", typeof(Lobby) },{ "400", typeof(ErrorStatus) },{ "403", typeof(ErrorStatus) },{ "404", typeof(ErrorStatus) },{ "409", typeof(ErrorStatus) } }; |
|||
|
|||
// Merge the operation/request level configuration with the client level configuration.
|
|||
var finalConfiguration = Configuration.MergeConfigurations(operationConfiguration, Configuration); |
|||
|
|||
var response = await HttpClient.MakeRequestAsync("POST", |
|||
request.ConstructUrl(finalConfiguration.BasePath), |
|||
request.ConstructBody(), |
|||
request.ConstructHeaders(_accessToken, finalConfiguration), |
|||
finalConfiguration.RequestTimeout); |
|||
|
|||
var handledResponse = ResponseHandler.HandleAsyncResponse<Lobby>(response, statusCodeToTypeMap); |
|||
return new Response<Lobby>(response, handledResponse); |
|||
} |
|||
|
|||
public async Task<Response> RemovePlayerAsync(RemovePlayerRequest request, |
|||
Configuration operationConfiguration = null) |
|||
{ |
|||
var statusCodeToTypeMap = new Dictionary<string, System.Type>() { { "204", null },{ "400", typeof(ErrorStatus) },{ "403", typeof(ErrorStatus) },{ "404", typeof(ErrorStatus) } }; |
|||
|
|||
// Merge the operation/request level configuration with the client level configuration.
|
|||
var finalConfiguration = Configuration.MergeConfigurations(operationConfiguration, Configuration); |
|||
|
|||
var response = await HttpClient.MakeRequestAsync("DELETE", |
|||
request.ConstructUrl(finalConfiguration.BasePath), |
|||
request.ConstructBody(), |
|||
request.ConstructHeaders(_accessToken, finalConfiguration), |
|||
finalConfiguration.RequestTimeout); |
|||
|
|||
ResponseHandler.HandleAsyncResponse(response, statusCodeToTypeMap); |
|||
return new Response(response); |
|||
} |
|||
|
|||
public async Task<Response<Lobby>> UpdateLobbyAsync(UpdateLobbyRequest request, |
|||
Configuration operationConfiguration = null) |
|||
{ |
|||
var statusCodeToTypeMap = new Dictionary<string, System.Type>() { { "200", typeof(Lobby) },{ "400", typeof(ErrorStatus) },{ "403", typeof(ErrorStatus) },{ "404", typeof(ErrorStatus) } }; |
|||
|
|||
// Merge the operation/request level configuration with the client level configuration.
|
|||
var finalConfiguration = Configuration.MergeConfigurations(operationConfiguration, Configuration); |
|||
|
|||
var response = await HttpClient.MakeRequestAsync("POST", |
|||
request.ConstructUrl(finalConfiguration.BasePath), |
|||
request.ConstructBody(), |
|||
request.ConstructHeaders(_accessToken, finalConfiguration), |
|||
finalConfiguration.RequestTimeout); |
|||
|
|||
var handledResponse = ResponseHandler.HandleAsyncResponse<Lobby>(response, statusCodeToTypeMap); |
|||
return new Response<Lobby>(response, handledResponse); |
|||
} |
|||
|
|||
public async Task<Response<Lobby>> UpdatePlayerAsync(UpdatePlayerRequest request, |
|||
Configuration operationConfiguration = null) |
|||
{ |
|||
var statusCodeToTypeMap = new Dictionary<string, System.Type>() { { "200", typeof(Lobby) },{ "400", typeof(ErrorStatus) },{ "403", typeof(ErrorStatus) },{ "404", typeof(ErrorStatus) } }; |
|||
|
|||
// Merge the operation/request level configuration with the client level configuration.
|
|||
var finalConfiguration = Configuration.MergeConfigurations(operationConfiguration, Configuration); |
|||
|
|||
var response = await HttpClient.MakeRequestAsync("POST", |
|||
request.ConstructUrl(finalConfiguration.BasePath), |
|||
request.ConstructBody(), |
|||
request.ConstructHeaders(_accessToken, finalConfiguration), |
|||
finalConfiguration.RequestTimeout); |
|||
|
|||
var handledResponse = ResponseHandler.HandleAsyncResponse<Lobby>(response, statusCodeToTypeMap); |
|||
return new Response<Lobby>(response, handledResponse); |
|||
} |
|||
|
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: c7af8c5a320294bc1af77f2e55c05745 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections.Generic; |
|||
using UnityEngine.Scripting; |
|||
using System.Text; |
|||
using System.Text.RegularExpressions; |
|||
using Newtonsoft.Json; |
|||
using Unity.Services.Lobbies.Http; |
|||
using UnityEngine; |
|||
using UnityEngine.Networking; |
|||
using Unity.Services.Lobbies.Models; |
|||
using Unity.Services.Authentication; |
|||
|
|||
namespace Unity.Services.Lobbies |
|||
{ |
|||
internal static class JsonSerialization |
|||
{ |
|||
public static byte[] Serialize<T>(T obj) |
|||
{ |
|||
return Encoding.UTF8.GetBytes(SerializeToString(obj)); |
|||
} |
|||
|
|||
public static string SerializeToString<T>(T obj) |
|||
{ |
|||
return JsonConvert.SerializeObject(obj); |
|||
} |
|||
} |
|||
[Preserve] |
|||
public class LobbyApiBaseRequest |
|||
{ |
|||
[Preserve] |
|||
public List<string> AddParamsToQueryParams(List<string> queryParams, string key, string value) |
|||
{ |
|||
key = UnityWebRequest.EscapeURL(key); |
|||
value = UnityWebRequest.EscapeURL(value); |
|||
queryParams.Add($"{key}={value}"); |
|||
return queryParams; |
|||
} |
|||
|
|||
[Preserve] |
|||
public List<string> AddParamsToQueryParams(List<string> queryParams, string key, List<string> values) |
|||
{ |
|||
foreach(var value in values) |
|||
{ |
|||
string escapedValue = UnityWebRequest.EscapeURL(value); |
|||
queryParams.Add($"{UnityWebRequest.EscapeURL(key)}[]={escapedValue}"); |
|||
} |
|||
return queryParams; |
|||
} |
|||
|
|||
[Preserve] |
|||
public List<string> AddParamsToQueryParams<T>(List<string> queryParams, string key, T value) |
|||
{ |
|||
key = UnityWebRequest.EscapeURL(key); |
|||
string valueString = UnityWebRequest.EscapeURL(value.ToString()); |
|||
queryParams.Add($"{key}={valueString}"); |
|||
return queryParams; |
|||
} |
|||
|
|||
public byte[] ConstructBody(System.IO.Stream stream) |
|||
{ |
|||
if (stream != null) |
|||
{ |
|||
using (System.IO.MemoryStream ms = new System.IO.MemoryStream()) |
|||
{ |
|||
stream.CopyTo(ms); |
|||
return ms.ToArray(); |
|||
} |
|||
} |
|||
return null; |
|||
} |
|||
|
|||
public byte[] ConstructBody(string s) |
|||
{ |
|||
return System.Text.Encoding.UTF8.GetBytes(s); |
|||
} |
|||
|
|||
public byte[] ConstructBody(object o) |
|||
{ |
|||
return JsonSerialization.Serialize(o); |
|||
} |
|||
|
|||
public string GenerateAcceptHeader(string[] accepts) |
|||
{ |
|||
if (accepts.Length == 0) |
|||
{ |
|||
return null; |
|||
} |
|||
for (int i = 0; i < accepts.Length; ++i) |
|||
{ |
|||
if (string.Equals(accepts[i], "application/json", System.StringComparison.OrdinalIgnoreCase)) |
|||
{ |
|||
return "application/json"; |
|||
} |
|||
} |
|||
return string.Join(", ", accepts); |
|||
} |
|||
|
|||
private static readonly Regex JsonRegex = new Regex(@"application\/json(;\s)?((charset=utf8|q=[0-1]\.\d)(\s)?)*"); |
|||
|
|||
public string GenerateContentTypeHeader(string[] contentTypes) |
|||
{ |
|||
if (contentTypes.Length == 0) |
|||
{ |
|||
return null; |
|||
} |
|||
|
|||
for(int i = 0; i < contentTypes.Length; ++i) |
|||
{ |
|||
if (!string.IsNullOrWhiteSpace(contentTypes[i]) && JsonRegex.IsMatch(contentTypes[i])) |
|||
{ |
|||
return contentTypes[i]; |
|||
} |
|||
} |
|||
return contentTypes[0]; |
|||
} |
|||
|
|||
public IMultipartFormSection GenerateMultipartFormFileSection(string paramName, System.IO.Stream stream, string contentType) |
|||
{ |
|||
if (stream is System.IO.FileStream) |
|||
{ |
|||
System.IO.FileStream fileStream = (System.IO.FileStream) stream; |
|||
return new MultipartFormFileSection(paramName, ConstructBody(fileStream), GetFileName(fileStream.Name), contentType); |
|||
} |
|||
return new MultipartFormDataSection(paramName, ConstructBody(stream)); |
|||
} |
|||
|
|||
private string GetFileName(string filePath) |
|||
{ |
|||
return System.IO.Path.GetFileName(filePath); |
|||
} |
|||
} |
|||
|
|||
[Preserve] |
|||
public class CreateLobbyRequest : LobbyApiBaseRequest |
|||
{ |
|||
[Preserve] |
|||
public CreateRequest CreateRequest { get; } |
|||
string PathAndQueryParams; |
|||
|
|||
/// <summary>
|
|||
/// CreateLobby Request Object.
|
|||
/// Create a lobby
|
|||
/// </summary>
|
|||
/// <param name="CreateRequest">CreateRequest param</param>
|
|||
/// <returns>A CreateLobby request object.</returns>
|
|||
[Preserve] |
|||
public CreateLobbyRequest(CreateRequest createRequest = default(CreateRequest)) |
|||
{ |
|||
CreateRequest = createRequest; |
|||
PathAndQueryParams = $"/create"; |
|||
|
|||
List<string> queryParams = new List<string>(); |
|||
|
|||
if (queryParams.Count > 0) |
|||
{ |
|||
PathAndQueryParams = $"{PathAndQueryParams}?{string.Join("&", queryParams)}"; |
|||
} |
|||
} |
|||
|
|||
public string ConstructUrl(string requestBasePath) |
|||
{ |
|||
return requestBasePath + PathAndQueryParams; |
|||
} |
|||
|
|||
public byte[] ConstructBody() |
|||
{ |
|||
if(CreateRequest != null) |
|||
{ |
|||
return ConstructBody(CreateRequest); |
|||
} |
|||
return null; |
|||
} |
|||
|
|||
public Dictionary<string, string> ConstructHeaders(IAccessToken accessToken, |
|||
Configuration operationConfiguration = null) |
|||
{ |
|||
var headers = new Dictionary<string, string>(); |
|||
if(!string.IsNullOrEmpty(accessToken.AccessToken)) |
|||
{ |
|||
headers.Add("authorization", "Bearer " + accessToken.AccessToken); |
|||
} |
|||
|
|||
string[] contentTypes = { |
|||
"application/json" |
|||
}; |
|||
|
|||
string[] accepts = { |
|||
"application/json", |
|||
"application/problem+json" |
|||
}; |
|||
|
|||
var acceptHeader = GenerateAcceptHeader(accepts); |
|||
if (!string.IsNullOrEmpty(acceptHeader)) |
|||
{ |
|||
headers.Add("Accept", acceptHeader); |
|||
} |
|||
var contentTypeHeader = GenerateContentTypeHeader(contentTypes); |
|||
if (!string.IsNullOrEmpty(contentTypeHeader)) |
|||
{ |
|||
headers.Add("Content-Type", contentTypeHeader); |
|||
} |
|||
|
|||
|
|||
// We also check if there are headers that are defined as part of
|
|||
// the request configuration.
|
|||
if (operationConfiguration != null && operationConfiguration.Headers != null) |
|||
{ |
|||
foreach (var pair in operationConfiguration.Headers) |
|||
{ |
|||
headers[pair.Key] = pair.Value; |
|||
} |
|||
} |
|||
|
|||
return headers; |
|||
} |
|||
} |
|||
[Preserve] |
|||
public class DeleteLobbyRequest : LobbyApiBaseRequest |
|||
{ |
|||
[Preserve] |
|||
public string LobbyId { get; } |
|||
string PathAndQueryParams; |
|||
|
|||
/// <summary>
|
|||
/// DeleteLobby Request Object.
|
|||
/// Delete a lobby
|
|||
/// </summary>
|
|||
/// <param name="lobbyId">The id of the lobby to execute the request against.</param>
|
|||
/// <returns>A DeleteLobby request object.</returns>
|
|||
[Preserve] |
|||
public DeleteLobbyRequest(string lobbyId) |
|||
{ |
|||
LobbyId = lobbyId; |
|||
PathAndQueryParams = $"/{lobbyId}"; |
|||
|
|||
List<string> queryParams = new List<string>(); |
|||
|
|||
if (queryParams.Count > 0) |
|||
{ |
|||
PathAndQueryParams = $"{PathAndQueryParams}?{string.Join("&", queryParams)}"; |
|||
} |
|||
} |
|||
|
|||
public string ConstructUrl(string requestBasePath) |
|||
{ |
|||
return requestBasePath + PathAndQueryParams; |
|||
} |
|||
|
|||
public byte[] ConstructBody() |
|||
{ |
|||
return null; |
|||
} |
|||
|
|||
public Dictionary<string, string> ConstructHeaders(IAccessToken accessToken, |
|||
Configuration operationConfiguration = null) |
|||
{ |
|||
var headers = new Dictionary<string, string>(); |
|||
if(!string.IsNullOrEmpty(accessToken.AccessToken)) |
|||
{ |
|||
headers.Add("authorization", "Bearer " + accessToken.AccessToken); |
|||
} |
|||
|
|||
string[] contentTypes = { |
|||
}; |
|||
|
|||
string[] accepts = { |
|||
"application/problem+json" |
|||
}; |
|||
|
|||
var acceptHeader = GenerateAcceptHeader(accepts); |
|||
if (!string.IsNullOrEmpty(acceptHeader)) |
|||
{ |
|||
headers.Add("Accept", acceptHeader); |
|||
} |
|||
var contentTypeHeader = GenerateContentTypeHeader(contentTypes); |
|||
if (!string.IsNullOrEmpty(contentTypeHeader)) |
|||
{ |
|||
headers.Add("Content-Type", contentTypeHeader); |
|||
} |
|||
|
|||
|
|||
// We also check if there are headers that are defined as part of
|
|||
// the request configuration.
|
|||
if (operationConfiguration != null && operationConfiguration.Headers != null) |
|||
{ |
|||
foreach (var pair in operationConfiguration.Headers) |
|||
{ |
|||
headers[pair.Key] = pair.Value; |
|||
} |
|||
} |
|||
|
|||
return headers; |
|||
} |
|||
} |
|||
[Preserve] |
|||
public class GetLobbyRequest : LobbyApiBaseRequest |
|||
{ |
|||
[Preserve] |
|||
public string LobbyId { get; } |
|||
string PathAndQueryParams; |
|||
|
|||
/// <summary>
|
|||
/// GetLobby Request Object.
|
|||
/// Get lobby details
|
|||
/// </summary>
|
|||
/// <param name="lobbyId">The id of the lobby to execute the request against.</param>
|
|||
/// <returns>A GetLobby request object.</returns>
|
|||
[Preserve] |
|||
public GetLobbyRequest(string lobbyId) |
|||
{ |
|||
LobbyId = lobbyId; |
|||
PathAndQueryParams = $"/{lobbyId}"; |
|||
|
|||
List<string> queryParams = new List<string>(); |
|||
|
|||
if (queryParams.Count > 0) |
|||
{ |
|||
PathAndQueryParams = $"{PathAndQueryParams}?{string.Join("&", queryParams)}"; |
|||
} |
|||
} |
|||
|
|||
public string ConstructUrl(string requestBasePath) |
|||
{ |
|||
return requestBasePath + PathAndQueryParams; |
|||
} |
|||
|
|||
public byte[] ConstructBody() |
|||
{ |
|||
return null; |
|||
} |
|||
|
|||
public Dictionary<string, string> ConstructHeaders(IAccessToken accessToken, |
|||
Configuration operationConfiguration = null) |
|||
{ |
|||
var headers = new Dictionary<string, string>(); |
|||
if(!string.IsNullOrEmpty(accessToken.AccessToken)) |
|||
{ |
|||
headers.Add("authorization", "Bearer " + accessToken.AccessToken); |
|||
} |
|||
|
|||
string[] contentTypes = { |
|||
}; |
|||
|
|||
string[] accepts = { |
|||
"application/json", |
|||
"application/problem+json" |
|||
}; |
|||
|
|||
var acceptHeader = GenerateAcceptHeader(accepts); |
|||
if (!string.IsNullOrEmpty(acceptHeader)) |
|||
{ |
|||
headers.Add("Accept", acceptHeader); |
|||
} |
|||
var contentTypeHeader = GenerateContentTypeHeader(contentTypes); |
|||
if (!string.IsNullOrEmpty(contentTypeHeader)) |
|||
{ |
|||
headers.Add("Content-Type", contentTypeHeader); |
|||
} |
|||
|
|||
|
|||
// We also check if there are headers that are defined as part of
|
|||
// the request configuration.
|
|||
if (operationConfiguration != null && operationConfiguration.Headers != null) |
|||
{ |
|||
foreach (var pair in operationConfiguration.Headers) |
|||
{ |
|||
headers[pair.Key] = pair.Value; |
|||
} |
|||
} |
|||
|
|||
return headers; |
|||
} |
|||
} |
|||
[Preserve] |
|||
public class JoinLobbyByCodeRequest : LobbyApiBaseRequest |
|||
{ |
|||
[Preserve] |
|||
public JoinByCodeRequest JoinByCodeRequest { get; } |
|||
string PathAndQueryParams; |
|||
|
|||
/// <summary>
|
|||
/// JoinLobbyByCode Request Object.
|
|||
/// Join a lobby with lobby code
|
|||
/// </summary>
|
|||
/// <param name="JoinByCodeRequest">JoinByCodeRequest param</param>
|
|||
/// <returns>A JoinLobbyByCode request object.</returns>
|
|||
[Preserve] |
|||
public JoinLobbyByCodeRequest(JoinByCodeRequest joinByCodeRequest = default(JoinByCodeRequest)) |
|||
{ |
|||
JoinByCodeRequest = joinByCodeRequest; |
|||
PathAndQueryParams = $"/joinbycode"; |
|||
|
|||
List<string> queryParams = new List<string>(); |
|||
|
|||
if (queryParams.Count > 0) |
|||
{ |
|||
PathAndQueryParams = $"{PathAndQueryParams}?{string.Join("&", queryParams)}"; |
|||
} |
|||
} |
|||
|
|||
public string ConstructUrl(string requestBasePath) |
|||
{ |
|||
return requestBasePath + PathAndQueryParams; |
|||
} |
|||
|
|||
public byte[] ConstructBody() |
|||
{ |
|||
if(JoinByCodeRequest != null) |
|||
{ |
|||
return ConstructBody(JoinByCodeRequest); |
|||
} |
|||
return null; |
|||
} |
|||
|
|||
public Dictionary<string, string> ConstructHeaders(IAccessToken accessToken, |
|||
Configuration operationConfiguration = null) |
|||
{ |
|||
var headers = new Dictionary<string, string>(); |
|||
if(!string.IsNullOrEmpty(accessToken.AccessToken)) |
|||
{ |
|||
headers.Add("authorization", "Bearer " + accessToken.AccessToken); |
|||
} |
|||
|
|||
string[] contentTypes = { |
|||
"application/json" |
|||
}; |
|||
|
|||
string[] accepts = { |
|||
"application/json", |
|||
"application/problem+json" |
|||
}; |
|||
|
|||
var acceptHeader = GenerateAcceptHeader(accepts); |
|||
if (!string.IsNullOrEmpty(acceptHeader)) |
|||
{ |
|||
headers.Add("Accept", acceptHeader); |
|||
} |
|||
var contentTypeHeader = GenerateContentTypeHeader(contentTypes); |
|||
if (!string.IsNullOrEmpty(contentTypeHeader)) |
|||
{ |
|||
headers.Add("Content-Type", contentTypeHeader); |
|||
} |
|||
|
|||
|
|||
// We also check if there are headers that are defined as part of
|
|||
// the request configuration.
|
|||
if (operationConfiguration != null && operationConfiguration.Headers != null) |
|||
{ |
|||
foreach (var pair in operationConfiguration.Headers) |
|||
{ |
|||
headers[pair.Key] = pair.Value; |
|||
} |
|||
} |
|||
|
|||
return headers; |
|||
} |
|||
} |
|||
[Preserve] |
|||
public class JoinLobbyByIdRequest : LobbyApiBaseRequest |
|||
{ |
|||
[Preserve] |
|||
public string LobbyId { get; } |
|||
[Preserve] |
|||
public Player Player { get; } |
|||
string PathAndQueryParams; |
|||
|
|||
/// <summary>
|
|||
/// JoinLobbyById Request Object.
|
|||
/// Join a lobby with lobby ID
|
|||
/// </summary>
|
|||
/// <param name="lobbyId">The id of the lobby to execute the request against.</param>
|
|||
/// <param name="Player">Player param</param>
|
|||
/// <returns>A JoinLobbyById request object.</returns>
|
|||
[Preserve] |
|||
public JoinLobbyByIdRequest(string lobbyId, Player player = default(Player)) |
|||
{ |
|||
LobbyId = lobbyId; |
|||
Player = player; |
|||
PathAndQueryParams = $"/{lobbyId}/join"; |
|||
|
|||
List<string> queryParams = new List<string>(); |
|||
|
|||
if (queryParams.Count > 0) |
|||
{ |
|||
PathAndQueryParams = $"{PathAndQueryParams}?{string.Join("&", queryParams)}"; |
|||
} |
|||
} |
|||
|
|||
public string ConstructUrl(string requestBasePath) |
|||
{ |
|||
return requestBasePath + PathAndQueryParams; |
|||
} |
|||
|
|||
public byte[] ConstructBody() |
|||
{ |
|||
if(Player != null) |
|||
{ |
|||
return ConstructBody(Player); |
|||
} |
|||
return null; |
|||
} |
|||
|
|||
public Dictionary<string, string> ConstructHeaders(IAccessToken accessToken, |
|||
Configuration operationConfiguration = null) |
|||
{ |
|||
var headers = new Dictionary<string, string>(); |
|||
if(!string.IsNullOrEmpty(accessToken.AccessToken)) |
|||
{ |
|||
headers.Add("authorization", "Bearer " + accessToken.AccessToken); |
|||
} |
|||
|
|||
string[] contentTypes = { |
|||
"application/json" |
|||
}; |
|||
|
|||
string[] accepts = { |
|||
"application/json", |
|||
"application/problem+json" |
|||
}; |
|||
|
|||
var acceptHeader = GenerateAcceptHeader(accepts); |
|||
if (!string.IsNullOrEmpty(acceptHeader)) |
|||
{ |
|||
headers.Add("Accept", acceptHeader); |
|||
} |
|||
var contentTypeHeader = GenerateContentTypeHeader(contentTypes); |
|||
if (!string.IsNullOrEmpty(contentTypeHeader)) |
|||
{ |
|||
headers.Add("Content-Type", contentTypeHeader); |
|||
} |
|||
|
|||
|
|||
// We also check if there are headers that are defined as part of
|
|||
// the request configuration.
|
|||
if (operationConfiguration != null && operationConfiguration.Headers != null) |
|||
{ |
|||
foreach (var pair in operationConfiguration.Headers) |
|||
{ |
|||
headers[pair.Key] = pair.Value; |
|||
} |
|||
} |
|||
|
|||
return headers; |
|||
} |
|||
} |
|||
[Preserve] |
|||
public class QueryLobbiesRequest : LobbyApiBaseRequest |
|||
{ |
|||
[Preserve] |
|||
public QueryRequest QueryRequest { get; } |
|||
string PathAndQueryParams; |
|||
|
|||
/// <summary>
|
|||
/// QueryLobbies Request Object.
|
|||
/// Query public lobbies
|
|||
/// </summary>
|
|||
/// <param name="QueryRequest">QueryRequest param</param>
|
|||
/// <returns>A QueryLobbies request object.</returns>
|
|||
[Preserve] |
|||
public QueryLobbiesRequest(QueryRequest queryRequest = default(QueryRequest)) |
|||
{ |
|||
QueryRequest = queryRequest; |
|||
PathAndQueryParams = $"/query"; |
|||
|
|||
List<string> queryParams = new List<string>(); |
|||
|
|||
if (queryParams.Count > 0) |
|||
{ |
|||
PathAndQueryParams = $"{PathAndQueryParams}?{string.Join("&", queryParams)}"; |
|||
} |
|||
} |
|||
|
|||
public string ConstructUrl(string requestBasePath) |
|||
{ |
|||
return requestBasePath + PathAndQueryParams; |
|||
} |
|||
|
|||
public byte[] ConstructBody() |
|||
{ |
|||
if(QueryRequest != null) |
|||
{ |
|||
return ConstructBody(QueryRequest); |
|||
} |
|||
return null; |
|||
} |
|||
|
|||
public Dictionary<string, string> ConstructHeaders(IAccessToken accessToken, |
|||
Configuration operationConfiguration = null) |
|||
{ |
|||
var headers = new Dictionary<string, string>(); |
|||
if(!string.IsNullOrEmpty(accessToken.AccessToken)) |
|||
{ |
|||
headers.Add("authorization", "Bearer " + accessToken.AccessToken); |
|||
} |
|||
|
|||
string[] contentTypes = { |
|||
"application/json" |
|||
}; |
|||
|
|||
string[] accepts = { |
|||
"application/json", |
|||
"application/problem+json" |
|||
}; |
|||
|
|||
var acceptHeader = GenerateAcceptHeader(accepts); |
|||
if (!string.IsNullOrEmpty(acceptHeader)) |
|||
{ |
|||
headers.Add("Accept", acceptHeader); |
|||
} |
|||
var contentTypeHeader = GenerateContentTypeHeader(contentTypes); |
|||
if (!string.IsNullOrEmpty(contentTypeHeader)) |
|||
{ |
|||
headers.Add("Content-Type", contentTypeHeader); |
|||
} |
|||
|
|||
|
|||
// We also check if there are headers that are defined as part of
|
|||
// the request configuration.
|
|||
if (operationConfiguration != null && operationConfiguration.Headers != null) |
|||
{ |
|||
foreach (var pair in operationConfiguration.Headers) |
|||
{ |
|||
headers[pair.Key] = pair.Value; |
|||
} |
|||
} |
|||
|
|||
return headers; |
|||
} |
|||
} |
|||
[Preserve] |
|||
public class QuickJoinLobbyRequest : LobbyApiBaseRequest |
|||
{ |
|||
[Preserve] |
|||
public QuickJoinRequest QuickJoinRequest { get; } |
|||
string PathAndQueryParams; |
|||
|
|||
/// <summary>
|
|||
/// QuickJoinLobby Request Object.
|
|||
/// Query available lobbies and join a random one
|
|||
/// </summary>
|
|||
/// <param name="QuickJoinRequest">QuickJoinRequest param</param>
|
|||
/// <returns>A QuickJoinLobby request object.</returns>
|
|||
[Preserve] |
|||
public QuickJoinLobbyRequest(QuickJoinRequest quickJoinRequest = default(QuickJoinRequest)) |
|||
{ |
|||
QuickJoinRequest = quickJoinRequest; |
|||
PathAndQueryParams = $"/quickjoin"; |
|||
|
|||
List<string> queryParams = new List<string>(); |
|||
|
|||
if (queryParams.Count > 0) |
|||
{ |
|||
PathAndQueryParams = $"{PathAndQueryParams}?{string.Join("&", queryParams)}"; |
|||
} |
|||
} |
|||
|
|||
public string ConstructUrl(string requestBasePath) |
|||
{ |
|||
return requestBasePath + PathAndQueryParams; |
|||
} |
|||
|
|||
public byte[] ConstructBody() |
|||
{ |
|||
if(QuickJoinRequest != null) |
|||
{ |
|||
return ConstructBody(QuickJoinRequest); |
|||
} |
|||
return null; |
|||
} |
|||
|
|||
public Dictionary<string, string> ConstructHeaders(IAccessToken accessToken, |
|||
Configuration operationConfiguration = null) |
|||
{ |
|||
var headers = new Dictionary<string, string>(); |
|||
if(!string.IsNullOrEmpty(accessToken.AccessToken)) |
|||
{ |
|||
headers.Add("authorization", "Bearer " + accessToken.AccessToken); |
|||
} |
|||
|
|||
string[] contentTypes = { |
|||
"application/json" |
|||
}; |
|||
|
|||
string[] accepts = { |
|||
"application/json", |
|||
"application/problem+json" |
|||
}; |
|||
|
|||
var acceptHeader = GenerateAcceptHeader(accepts); |
|||
if (!string.IsNullOrEmpty(acceptHeader)) |
|||
{ |
|||
headers.Add("Accept", acceptHeader); |
|||
} |
|||
var contentTypeHeader = GenerateContentTypeHeader(contentTypes); |
|||
if (!string.IsNullOrEmpty(contentTypeHeader)) |
|||
{ |
|||
headers.Add("Content-Type", contentTypeHeader); |
|||
} |
|||
|
|||
|
|||
// We also check if there are headers that are defined as part of
|
|||
// the request configuration.
|
|||
if (operationConfiguration != null && operationConfiguration.Headers != null) |
|||
{ |
|||
foreach (var pair in operationConfiguration.Headers) |
|||
{ |
|||
headers[pair.Key] = pair.Value; |
|||
} |
|||
} |
|||
|
|||
return headers; |
|||
} |
|||
} |
|||
[Preserve] |
|||
public class RemovePlayerRequest : LobbyApiBaseRequest |
|||
{ |
|||
[Preserve] |
|||
public string LobbyId { get; } |
|||
[Preserve] |
|||
public string PlayerId { get; } |
|||
string PathAndQueryParams; |
|||
|
|||
/// <summary>
|
|||
/// RemovePlayer Request Object.
|
|||
/// Remove a player
|
|||
/// </summary>
|
|||
/// <param name="lobbyId">The id of the lobby to execute the request against.</param>
|
|||
/// <param name="playerId">The id of the player to execute the request against.</param>
|
|||
/// <returns>A RemovePlayer request object.</returns>
|
|||
[Preserve] |
|||
public RemovePlayerRequest(string lobbyId, string playerId) |
|||
{ |
|||
LobbyId = lobbyId; |
|||
PlayerId = playerId; |
|||
PathAndQueryParams = $"/{lobbyId}/players/{playerId}"; |
|||
|
|||
List<string> queryParams = new List<string>(); |
|||
|
|||
if (queryParams.Count > 0) |
|||
{ |
|||
PathAndQueryParams = $"{PathAndQueryParams}?{string.Join("&", queryParams)}"; |
|||
} |
|||
} |
|||
|
|||
public string ConstructUrl(string requestBasePath) |
|||
{ |
|||
return requestBasePath + PathAndQueryParams; |
|||
} |
|||
|
|||
public byte[] ConstructBody() |
|||
{ |
|||
return null; |
|||
} |
|||
|
|||
public Dictionary<string, string> ConstructHeaders(IAccessToken accessToken, |
|||
Configuration operationConfiguration = null) |
|||
{ |
|||
var headers = new Dictionary<string, string>(); |
|||
if(!string.IsNullOrEmpty(accessToken.AccessToken)) |
|||
{ |
|||
headers.Add("authorization", "Bearer " + accessToken.AccessToken); |
|||
} |
|||
|
|||
string[] contentTypes = { |
|||
}; |
|||
|
|||
string[] accepts = { |
|||
"application/problem+json" |
|||
}; |
|||
|
|||
var acceptHeader = GenerateAcceptHeader(accepts); |
|||
if (!string.IsNullOrEmpty(acceptHeader)) |
|||
{ |
|||
headers.Add("Accept", acceptHeader); |
|||
} |
|||
var contentTypeHeader = GenerateContentTypeHeader(contentTypes); |
|||
if (!string.IsNullOrEmpty(contentTypeHeader)) |
|||
{ |
|||
headers.Add("Content-Type", contentTypeHeader); |
|||
} |
|||
|
|||
|
|||
// We also check if there are headers that are defined as part of
|
|||
// the request configuration.
|
|||
if (operationConfiguration != null && operationConfiguration.Headers != null) |
|||
{ |
|||
foreach (var pair in operationConfiguration.Headers) |
|||
{ |
|||
headers[pair.Key] = pair.Value; |
|||
} |
|||
} |
|||
|
|||
return headers; |
|||
} |
|||
} |
|||
[Preserve] |
|||
public class UpdateLobbyRequest : LobbyApiBaseRequest |
|||
{ |
|||
[Preserve] |
|||
public string LobbyId { get; } |
|||
[Preserve] |
|||
public UpdateRequest UpdateRequest { get; } |
|||
string PathAndQueryParams; |
|||
|
|||
/// <summary>
|
|||
/// UpdateLobby Request Object.
|
|||
/// Update lobby data
|
|||
/// </summary>
|
|||
/// <param name="lobbyId">The id of the lobby to execute the request against.</param>
|
|||
/// <param name="UpdateRequest">UpdateRequest param</param>
|
|||
/// <returns>A UpdateLobby request object.</returns>
|
|||
[Preserve] |
|||
public UpdateLobbyRequest(string lobbyId, UpdateRequest updateRequest = default(UpdateRequest)) |
|||
{ |
|||
LobbyId = lobbyId; |
|||
UpdateRequest = updateRequest; |
|||
PathAndQueryParams = $"/{lobbyId}"; |
|||
|
|||
List<string> queryParams = new List<string>(); |
|||
|
|||
if (queryParams.Count > 0) |
|||
{ |
|||
PathAndQueryParams = $"{PathAndQueryParams}?{string.Join("&", queryParams)}"; |
|||
} |
|||
} |
|||
|
|||
public string ConstructUrl(string requestBasePath) |
|||
{ |
|||
return requestBasePath + PathAndQueryParams; |
|||
} |
|||
|
|||
public byte[] ConstructBody() |
|||
{ |
|||
if(UpdateRequest != null) |
|||
{ |
|||
return ConstructBody(UpdateRequest); |
|||
} |
|||
return null; |
|||
} |
|||
|
|||
public Dictionary<string, string> ConstructHeaders(IAccessToken accessToken, |
|||
Configuration operationConfiguration = null) |
|||
{ |
|||
var headers = new Dictionary<string, string>(); |
|||
if(!string.IsNullOrEmpty(accessToken.AccessToken)) |
|||
{ |
|||
headers.Add("authorization", "Bearer " + accessToken.AccessToken); |
|||
} |
|||
|
|||
string[] contentTypes = { |
|||
"application/json" |
|||
}; |
|||
|
|||
string[] accepts = { |
|||
"application/json", |
|||
"application/problem+json" |
|||
}; |
|||
|
|||
var acceptHeader = GenerateAcceptHeader(accepts); |
|||
if (!string.IsNullOrEmpty(acceptHeader)) |
|||
{ |
|||
headers.Add("Accept", acceptHeader); |
|||
} |
|||
var contentTypeHeader = GenerateContentTypeHeader(contentTypes); |
|||
if (!string.IsNullOrEmpty(contentTypeHeader)) |
|||
{ |
|||
headers.Add("Content-Type", contentTypeHeader); |
|||
} |
|||
|
|||
|
|||
// We also check if there are headers that are defined as part of
|
|||
// the request configuration.
|
|||
if (operationConfiguration != null && operationConfiguration.Headers != null) |
|||
{ |
|||
foreach (var pair in operationConfiguration.Headers) |
|||
{ |
|||
headers[pair.Key] = pair.Value; |
|||
} |
|||
} |
|||
|
|||
return headers; |
|||
} |
|||
} |
|||
[Preserve] |
|||
public class UpdatePlayerRequest : LobbyApiBaseRequest |
|||
{ |
|||
[Preserve] |
|||
public string LobbyId { get; } |
|||
[Preserve] |
|||
public string PlayerId { get; } |
|||
[Preserve] |
|||
public PlayerUpdateRequest PlayerUpdateRequest { get; } |
|||
string PathAndQueryParams; |
|||
|
|||
/// <summary>
|
|||
/// UpdatePlayer Request Object.
|
|||
/// Update player data
|
|||
/// </summary>
|
|||
/// <param name="lobbyId">The id of the lobby to execute the request against.</param>
|
|||
/// <param name="playerId">The id of the player to execute the request against.</param>
|
|||
/// <param name="PlayerUpdateRequest">PlayerUpdateRequest param</param>
|
|||
/// <returns>A UpdatePlayer request object.</returns>
|
|||
[Preserve] |
|||
public UpdatePlayerRequest(string lobbyId, string playerId, PlayerUpdateRequest playerUpdateRequest = default(PlayerUpdateRequest)) |
|||
{ |
|||
LobbyId = lobbyId; |
|||
PlayerId = playerId; |
|||
PlayerUpdateRequest = playerUpdateRequest; |
|||
PathAndQueryParams = $"/{lobbyId}/players/{playerId}"; |
|||
|
|||
List<string> queryParams = new List<string>(); |
|||
|
|||
if (queryParams.Count > 0) |
|||
{ |
|||
PathAndQueryParams = $"{PathAndQueryParams}?{string.Join("&", queryParams)}"; |
|||
} |
|||
} |
|||
|
|||
public string ConstructUrl(string requestBasePath) |
|||
{ |
|||
return requestBasePath + PathAndQueryParams; |
|||
} |
|||
|
|||
public byte[] ConstructBody() |
|||
{ |
|||
if(PlayerUpdateRequest != null) |
|||
{ |
|||
return ConstructBody(PlayerUpdateRequest); |
|||
} |
|||
return null; |
|||
} |
|||
|
|||
public Dictionary<string, string> ConstructHeaders(IAccessToken accessToken, |
|||
Configuration operationConfiguration = null) |
|||
{ |
|||
var headers = new Dictionary<string, string>(); |
|||
if(!string.IsNullOrEmpty(accessToken.AccessToken)) |
|||
{ |
|||
headers.Add("authorization", "Bearer " + accessToken.AccessToken); |
|||
} |
|||
|
|||
string[] contentTypes = { |
|||
"application/json" |
|||
}; |
|||
|
|||
string[] accepts = { |
|||
"application/json", |
|||
"application/problem+json" |
|||
}; |
|||
|
|||
var acceptHeader = GenerateAcceptHeader(accepts); |
|||
if (!string.IsNullOrEmpty(acceptHeader)) |
|||
{ |
|||
headers.Add("Accept", acceptHeader); |
|||
} |
|||
var contentTypeHeader = GenerateContentTypeHeader(contentTypes); |
|||
if (!string.IsNullOrEmpty(contentTypeHeader)) |
|||
{ |
|||
headers.Add("Content-Type", contentTypeHeader); |
|||
} |
|||
|
|||
|
|||
// We also check if there are headers that are defined as part of
|
|||
// the request configuration.
|
|||
if (operationConfiguration != null && operationConfiguration.Headers != null) |
|||
{ |
|||
foreach (var pair in operationConfiguration.Headers) |
|||
{ |
|||
headers[pair.Key] = pair.Value; |
|||
} |
|||
} |
|||
|
|||
return headers; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 64b9cb702300a4c4daaba9fbaf481895 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 8378769f08eee49db8d248bce33da040 |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections.Generic; |
|||
|
|||
namespace Unity.Services.Lobbies |
|||
{ |
|||
/// <summary>
|
|||
/// Represents a set of configuration settings
|
|||
/// </summary>
|
|||
public class Configuration |
|||
{ |
|||
public string BasePath; |
|||
public int RequestTimeout; |
|||
public int NumberOfRetries; |
|||
public IDictionary<string, string> Headers; |
|||
|
|||
|
|||
public Configuration(string basePath, int requestTimeout, int numRetries, IDictionary<string, string> headers) |
|||
{ |
|||
BasePath = basePath; |
|||
RequestTimeout = requestTimeout; |
|||
NumberOfRetries = numRetries; |
|||
Headers = headers; |
|||
} |
|||
|
|||
// Helper function for merging two configurations. Configuration `a` is
|
|||
// considered the base configuration if it is a valid object. Certain
|
|||
// values will be overridden if they are set to null within this
|
|||
// configuration by configuration `b` and the headers will be merged.
|
|||
public static Configuration MergeConfigurations(Configuration a, Configuration b) |
|||
{ |
|||
// Check if either inputs are `null`, if they are, we return
|
|||
// whichever is not `null`, if both are `null`, we return `b` which
|
|||
// will be `null`.
|
|||
if(a == null || b == null) |
|||
{ |
|||
return a ?? b; |
|||
} |
|||
|
|||
Configuration mergedConfig = a; |
|||
|
|||
if(mergedConfig.BasePath == null) |
|||
{ |
|||
mergedConfig.BasePath = b.BasePath; |
|||
} |
|||
|
|||
var headers = new Dictionary<string, string>(); |
|||
|
|||
if (b.Headers != null) |
|||
{ |
|||
foreach (var pair in b.Headers) |
|||
{ |
|||
headers[pair.Key] = pair.Value; |
|||
} |
|||
} |
|||
|
|||
if (mergedConfig.Headers != null) |
|||
{ |
|||
foreach (var pair in mergedConfig.Headers) |
|||
{ |
|||
headers[pair.Key] = pair.Value; |
|||
} |
|||
} |
|||
|
|||
mergedConfig.Headers = headers; |
|||
|
|||
|
|||
return mergedConfig; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 9988cff83b7ea44829092d70024c5abb |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: cf706965f45104f979462ef65d1f4db8 |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections; |
|||
using UnityEngine; |
|||
|
|||
namespace Unity.Services.Lobbies.Helpers |
|||
{ |
|||
internal static class AsyncOpRetry |
|||
{ |
|||
public static AsyncOpRetry<T> FromCreateAsync<T>(Func<int, T> op) |
|||
{ |
|||
return AsyncOpRetry<T>.FromCreateAsync(op); |
|||
} |
|||
} |
|||
|
|||
internal class AsyncOpRetry<T> |
|||
{ |
|||
private uint MaxRetries { get; set; } = 4; |
|||
private float JitterMagnitude { get; set; } = 1.0f; |
|||
private float DelayScale { get; set; } = 1.0f; |
|||
private float MaxDelayTime { get; set; } = 8.0f; |
|||
private Func<int, T> CreateOperation { get; set; } |
|||
private Func<T, bool> RetryCondition { get; set; } |
|||
private Action<T> OnComplete { get; set; } |
|||
|
|||
private AsyncOpRetry(Func<int, T> createAsyncOp) |
|||
{ |
|||
CreateOperation = createAsyncOp; |
|||
} |
|||
|
|||
private static float AddJitter(float number, float magnitude) |
|||
{ |
|||
return number + (UnityEngine.Random.value * magnitude); |
|||
} |
|||
|
|||
private static float Pow2(float exponent, float scale) |
|||
{ |
|||
return (float) (Math.Pow(2.0f, exponent) * scale); |
|||
} |
|||
|
|||
private static float CalculateDelay(int attemptNumber, float maxDelayTime, float delayScale, |
|||
float jitterMagnitude) |
|||
{ |
|||
float delayTime = Pow2(attemptNumber, delayScale); |
|||
delayTime = AddJitter(delayTime, jitterMagnitude); |
|||
delayTime = Math.Min(delayTime, maxDelayTime); |
|||
return delayTime; |
|||
} |
|||
|
|||
public AsyncOpRetry<T> WithJitterMagnitude(float magnitude) |
|||
{ |
|||
JitterMagnitude = Mathf.Clamp(magnitude, 0.001f, 1.0f); |
|||
return this; |
|||
} |
|||
|
|||
public AsyncOpRetry<T> WithDelayScale(float scale) |
|||
{ |
|||
DelayScale = Mathf.Clamp(scale, 0.05f, 1.0f); |
|||
return this; |
|||
} |
|||
|
|||
public AsyncOpRetry<T> WithMaxDelayTime(float time) |
|||
{ |
|||
MaxDelayTime = Mathf.Clamp(time, 0.1f, 60.0f); |
|||
return this; |
|||
} |
|||
|
|||
public static AsyncOpRetry<T> FromCreateAsync(Func<int, T> op) |
|||
{ |
|||
return new AsyncOpRetry<T>(op); |
|||
} |
|||
|
|||
public AsyncOpRetry<T> WithRetryCondition(Func<T, bool> shouldRetry) |
|||
{ |
|||
RetryCondition = shouldRetry; |
|||
return this; |
|||
} |
|||
|
|||
public AsyncOpRetry<T> WhenComplete(Action<T> onComplete) |
|||
{ |
|||
OnComplete = onComplete; |
|||
return this; |
|||
} |
|||
|
|||
public AsyncOpRetry<T> UptoMaximumRetries(uint amount) |
|||
{ |
|||
MaxRetries = amount; |
|||
return this; |
|||
} |
|||
|
|||
public IEnumerator Run() |
|||
{ |
|||
T asyncOp = default; |
|||
for (var attempt = 0; attempt <= MaxRetries; ++attempt) |
|||
{ |
|||
asyncOp = CreateOperation(attempt + 1); |
|||
yield return asyncOp; |
|||
|
|||
if ((!RetryCondition?.Invoke(asyncOp) ?? false)) |
|||
{ |
|||
break; |
|||
} |
|||
|
|||
var delayTime = CalculateDelay(attempt, MaxDelayTime, DelayScale, JitterMagnitude); |
|||
yield return new WaitForSecondsRealtime(delayTime); |
|||
} |
|||
OnComplete?.Invoke(asyncOp); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 37b7bcef9963d48188ca7b0038055962 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using Unity.Services.Lobbies.Scheduler; |
|||
|
|||
namespace Unity.Services.Lobbies.Http |
|||
{ |
|||
public abstract class BaseApiClient |
|||
{ |
|||
protected readonly IHttpClient HttpClient; |
|||
|
|||
public BaseApiClient(IHttpClient httpClient, TaskScheduler scheduler) |
|||
{ |
|||
HttpClient = httpClient ?? new HttpClient(scheduler); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 03b4179fd44124cd588f07100556556e |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using Newtonsoft.Json; |
|||
using UnityEngine.Scripting; |
|||
|
|||
namespace Unity.Services.Lobbies.Http |
|||
{ |
|||
[Preserve] |
|||
public class BasicError: IError |
|||
{ |
|||
[Preserve] |
|||
public string Type { get; } |
|||
[Preserve] |
|||
public string Title { get; } |
|||
[Preserve] |
|||
public int? Status { get; } |
|||
[Preserve] |
|||
public int Code { get; } |
|||
[Preserve] |
|||
public string Detail { get; } |
|||
|
|||
[Preserve] |
|||
public BasicError(string type, string title, int? status, int code, string detail) |
|||
{ |
|||
Type = type; |
|||
Title = title; |
|||
Status = status; |
|||
Code = code; |
|||
Detail = detail; |
|||
} |
|||
|
|||
public override string ToString() |
|||
{ |
|||
return JsonConvert.SerializeObject(this); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: f672b4837a01948d79e2e762cf3d2fcc |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
namespace Unity.Services.Lobbies.Http |
|||
{ |
|||
static internal class CommonErrors |
|||
{ |
|||
private const string ErrorPrefix = "com.unity.services.lobby"; |
|||
|
|||
public static IError CreateUnspecifiedHttpError(string details) |
|||
{ |
|||
return new BasicError( |
|||
$"{ErrorPrefix}http.httperror", |
|||
"Unspecified HTTP error", |
|||
null, |
|||
0, |
|||
details |
|||
); |
|||
} |
|||
|
|||
public static IError RequestOnSuccessNull => new BasicError( |
|||
$"{ErrorPrefix}onsuccessnullerror", |
|||
"Request must have an onSuccess callback", |
|||
null, |
|||
0, //TODO: define a code space for SDK side errors so all errors can be identified by a code
|
|||
""); |
|||
|
|||
|
|||
public static IError HttpNetworkError => new BasicError( |
|||
$"{ErrorPrefix}httpclient.networkerror", |
|||
"Network Error", |
|||
null, |
|||
0, |
|||
"" |
|||
); |
|||
|
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: d6100b420dfec472389e264a9e0879d4 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
|
|||
namespace Unity.Services.Lobbies.Http |
|||
{ |
|||
[Serializable] |
|||
public class DeserializationException : Exception |
|||
{ |
|||
public HttpClientResponse response; |
|||
|
|||
public DeserializationException() : base() |
|||
{ |
|||
} |
|||
|
|||
public DeserializationException(string message) : base(message) |
|||
{ |
|||
} |
|||
|
|||
DeserializationException(string message, Exception inner) : base(message, inner) |
|||
{ |
|||
} |
|||
|
|||
public DeserializationException(HttpClientResponse httpClientResponse) : base( |
|||
"Unable to Deserialize Http Client Response") |
|||
{ |
|||
response = httpClientResponse; |
|||
} |
|||
|
|||
public DeserializationException(HttpClientResponse httpClientResponse, string message) : base( |
|||
message) |
|||
{ |
|||
response = httpClientResponse; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 7794414098b5f4262a2e32e5aba969fd |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using System.Text; |
|||
using System.Threading; |
|||
using UnityEngine.Networking; |
|||
using System.Threading.Tasks; |
|||
using Unity.Services.Lobbies.Helpers; |
|||
using Unity.Services.Lobbies.Scheduler; |
|||
using TaskScheduler = Unity.Services.Lobbies.Scheduler.TaskScheduler; |
|||
|
|||
namespace Unity.Services.Lobbies.Http |
|||
{ |
|||
public class HttpClient : IHttpClient |
|||
{ |
|||
private static readonly HashSet<string> DisallowedHeaders = new HashSet<string> |
|||
{ |
|||
"accept-charset", "access-control-request-headers", "access-control-request-method", "connection", "date", |
|||
"dnt", "expect", "host", "keep-alive", "origin", "referer", "te", "trailer", "transfer-encoding", "upgrade", |
|||
"via", "content-length", "x-unity-version", "user-agent", "cookie", "cookie2" |
|||
}; |
|||
|
|||
private static readonly List<int> ErrorCodes = new List<int> {408, 500, 502, 503, 504}; |
|||
private TaskScheduler _scheduler; |
|||
|
|||
public HttpClient(TaskScheduler scheduler) |
|||
{ |
|||
_scheduler = scheduler; |
|||
} |
|||
|
|||
public void Get(string url, Dictionary<string, string> headers, Action<HttpClientResponse> onCompleted, |
|||
int requestTimeout = 10) |
|||
{ |
|||
_scheduler.ScheduleMainThreadTask(() => |
|||
{ |
|||
_scheduler.StartCoroutine(ProcessRequest(UnityWebRequest.kHttpVerbGET, url, headers, null, |
|||
requestTimeout, onCompleted)); |
|||
}); |
|||
} |
|||
|
|||
public void Delete(string url, Dictionary<string, string> headers, Action<HttpClientResponse> onCompleted, |
|||
int requestTimeout = 10) |
|||
{ |
|||
_scheduler.ScheduleMainThreadTask(() => |
|||
{ |
|||
_scheduler.StartCoroutine(ProcessRequest(UnityWebRequest.kHttpVerbDELETE, url, headers, null, |
|||
requestTimeout, onCompleted)); |
|||
}); |
|||
} |
|||
|
|||
public void Post(string url, byte[] body, Dictionary<string, string> headers, |
|||
Action<HttpClientResponse> onCompleted, int requestTimeout = 10) |
|||
{ |
|||
_scheduler.ScheduleMainThreadTask(() => |
|||
{ |
|||
_scheduler.StartCoroutine(ProcessRequest(UnityWebRequest.kHttpVerbPOST, url, headers, body, |
|||
requestTimeout, onCompleted)); |
|||
}); |
|||
} |
|||
|
|||
public void Put(string url, byte[] body, Dictionary<string, string> headers, |
|||
Action<HttpClientResponse> onCompleted, int requestTimeout = 10) |
|||
{ |
|||
_scheduler.ScheduleMainThreadTask(() => |
|||
{ |
|||
_scheduler.StartCoroutine(ProcessRequest(UnityWebRequest.kHttpVerbPUT, url, headers, body, |
|||
requestTimeout, onCompleted)); |
|||
}); |
|||
} |
|||
|
|||
public void MakeRequest(string method, string url, byte[] body, Dictionary<string, string> headers, |
|||
Action<HttpClientResponse> onCompleted, int requestTimeout = 10) |
|||
{ |
|||
_scheduler.ScheduleMainThreadTask(() => |
|||
{ |
|||
_scheduler.StartCoroutine(ProcessRequest(method.ToUpper(), url, headers, body, requestTimeout, |
|||
onCompleted)); |
|||
}); |
|||
} |
|||
|
|||
public async Task<HttpClientResponse> MakeRequestAsync(string method, string url, byte[] body, |
|||
Dictionary<string, string> headers, int requestTimeout) |
|||
{ |
|||
return await CreateWebRequestAsync(method.ToUpper(), url, body, headers, requestTimeout); |
|||
} |
|||
|
|||
public async Task<HttpClientResponse> MakeRequestAsync(string method, string url, |
|||
List<IMultipartFormSection> body, |
|||
Dictionary<string, string> headers, int requestTimeout, string boundary = null) |
|||
{ |
|||
return await CreateWebRequestAsync(method.ToUpper(), url, body, headers, requestTimeout, boundary); |
|||
} |
|||
|
|||
private IEnumerator ProcessRequest(string method, string url, IDictionary<string, string> headers, byte[] body, |
|||
int requestTimeout, Action<HttpClientResponse> onCompleted) |
|||
{ |
|||
UnityWebRequestAsyncOperation SetupRequest(int attempt) |
|||
{ |
|||
var webRequest = CreateWebRequest(method, url, body, headers, requestTimeout); |
|||
return webRequest.SendWebRequest(); |
|||
} |
|||
|
|||
bool ShouldRetry(UnityWebRequestAsyncOperation request) |
|||
{ |
|||
var responseCode = (int) request.webRequest.responseCode; |
|||
return ErrorCodes.Contains(responseCode); |
|||
} |
|||
|
|||
void AsyncOpCompleted(UnityWebRequestAsyncOperation request) |
|||
{ |
|||
var internalResponse = UnityWebRequestHelpers.CreateHttpClientResponse(request); |
|||
onCompleted(internalResponse); |
|||
} |
|||
|
|||
yield return AsyncOpRetry.FromCreateAsync(SetupRequest) |
|||
.WithRetryCondition(ShouldRetry) |
|||
.WhenComplete(AsyncOpCompleted) |
|||
.Run(); |
|||
} |
|||
|
|||
private UnityWebRequest CreateWebRequest(string method, string url, byte[] body, |
|||
IDictionary<string, string> headers, int requestTimeout = 10) |
|||
{ |
|||
using (var request = new UnityWebRequest(url, method)) |
|||
{ |
|||
foreach (var header in headers) |
|||
{ |
|||
if (DisallowedHeaders.Contains(header.Key.ToLower())) |
|||
{ |
|||
continue; |
|||
} |
|||
|
|||
request.SetRequestHeader(header.Key, header.Value); |
|||
} |
|||
|
|||
request.timeout = requestTimeout; |
|||
if (body != null && (method == UnityWebRequest.kHttpVerbPOST || method == UnityWebRequest.kHttpVerbPUT || |
|||
method == "PATCH")) |
|||
{ |
|||
request.uploadHandler = new UploadHandlerRaw(body); |
|||
} |
|||
|
|||
request.downloadHandler = new DownloadHandlerBuffer(); |
|||
return request; |
|||
} |
|||
} |
|||
|
|||
private async Task<HttpClientResponse> CreateWebRequestAsync(string method, string url, byte[] body, |
|||
IDictionary<string, string> headers, int requestTimeout) |
|||
{ |
|||
var result = await await Task.Factory.StartNew(async () => |
|||
{ |
|||
using (var request = new UnityWebRequest(url, method)) |
|||
{ |
|||
foreach (var header in headers) |
|||
{ |
|||
request.SetRequestHeader(header.Key, header.Value); |
|||
} |
|||
|
|||
request.timeout = requestTimeout; |
|||
if (body != null && (method == UnityWebRequest.kHttpVerbPOST || |
|||
method == UnityWebRequest.kHttpVerbPUT || |
|||
method == "PATCH")) |
|||
{ |
|||
request.uploadHandler = new UploadHandlerRaw(body); |
|||
} |
|||
|
|||
request.downloadHandler = new DownloadHandlerBuffer(); |
|||
return await request.SendWebRequest(); |
|||
} |
|||
|
|||
}, CancellationToken.None, TaskCreationOptions.None, |
|||
Scheduler.ThreadHelper.TaskScheduler); |
|||
return result; |
|||
} |
|||
|
|||
private async Task<HttpClientResponse> CreateWebRequestAsync(string method, string url, |
|||
List<IMultipartFormSection> body, |
|||
IDictionary<string, string> headers, int requestTimeout, string boundary = null) |
|||
{ |
|||
var result = await await Task.Factory.StartNew(async () => |
|||
{ |
|||
byte[] boundaryBytes = string.IsNullOrEmpty(boundary) |
|||
? UnityWebRequest.GenerateBoundary() |
|||
: Encoding.Default.GetBytes(boundary); |
|||
var request = new UnityWebRequest(url, method); |
|||
|
|||
foreach (var header in headers) |
|||
{ |
|||
request.SetRequestHeader(header.Key, header.Value); |
|||
} |
|||
|
|||
request.timeout = requestTimeout; |
|||
request = SetupMultipartRequest(request, body, boundaryBytes); |
|||
request.downloadHandler = new DownloadHandlerBuffer(); |
|||
|
|||
return await request.SendWebRequest(); |
|||
}, CancellationToken.None, TaskCreationOptions.None, |
|||
Scheduler.ThreadHelper.TaskScheduler); |
|||
return result; |
|||
} |
|||
|
|||
private static UnityWebRequest SetupMultipartRequest(UnityWebRequest request, |
|||
List<IMultipartFormSection> multipartFormSections, byte[] boundary) |
|||
{ |
|||
byte[] data = (byte[]) null; |
|||
if (multipartFormSections != null && (uint) multipartFormSections.Count > 0U) |
|||
{ |
|||
data = UnityWebRequest.SerializeFormSections(multipartFormSections, boundary); |
|||
} |
|||
|
|||
UploadHandler uploadHandler = (UploadHandler) new UploadHandlerRaw(data); |
|||
uploadHandler.contentType = |
|||
"multipart/form-data; boundary=" + Encoding.UTF8.GetString(boundary, 0, boundary.Length); |
|||
request.uploadHandler = uploadHandler; |
|||
request.downloadHandler = (DownloadHandler) new DownloadHandlerBuffer(); |
|||
|
|||
return request; |
|||
} |
|||
|
|||
internal static HttpClientResponse CreateHttpClientResponse(UnityWebRequestAsyncOperation unityResponse) |
|||
{ |
|||
var response = unityResponse.webRequest; |
|||
var result = new HttpClientResponse( |
|||
response.GetResponseHeaders(), |
|||
response.responseCode, |
|||
#if UNITY_2020_1_OR_NEWER
|
|||
response.result == UnityWebRequest.Result.ProtocolError, |
|||
response.result == UnityWebRequest.Result.ConnectionError, |
|||
#else
|
|||
response.isHttpError, |
|||
response.isNetworkError, |
|||
#endif
|
|||
response.downloadHandler.data, |
|||
response.error); |
|||
return result; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: dbca5ac37bded4161be07ed40f927cf4 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
|
|||
namespace Unity.Services.Lobbies.Http |
|||
{ |
|||
public class HttpClientResponse |
|||
{ |
|||
public HttpClientResponse(Dictionary<string, string> headers, long statusCode, bool isHttpError, bool isNetworkError, byte[] data, string errorMessage) |
|||
{ |
|||
Headers = headers; |
|||
StatusCode = statusCode; |
|||
IsHttpError = isHttpError; |
|||
IsNetworkError = isNetworkError; |
|||
Data = data; |
|||
ErrorMessage = errorMessage; |
|||
} |
|||
|
|||
public Dictionary<string, string> Headers { get; } |
|||
public long StatusCode { get; } |
|||
public bool IsHttpError { get; } |
|||
public bool IsNetworkError { get; } |
|||
public byte[] Data { get;} |
|||
public string ErrorMessage { get; } |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: a4910ef67265c45e5ac52936c11bf247 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using Unity.Services.Lobbies; |
|||
|
|||
namespace Unity.Services.Lobbies.Http |
|||
{ |
|||
[Serializable] |
|||
public class HttpException : Exception |
|||
{ |
|||
public HttpClientResponse Response; |
|||
|
|||
public HttpException() : base() |
|||
{ |
|||
} |
|||
|
|||
public HttpException(string message) : base(message) |
|||
{ |
|||
} |
|||
|
|||
public HttpException(string message, Exception inner) : base(message, inner) |
|||
{ |
|||
} |
|||
|
|||
public HttpException(HttpClientResponse response) : base(response.ErrorMessage) |
|||
{ |
|||
Response = response; |
|||
} |
|||
} |
|||
|
|||
[Serializable] |
|||
public class HttpException<T> : HttpException |
|||
{ |
|||
public T ActualError; |
|||
|
|||
public HttpException() : base() |
|||
{ |
|||
} |
|||
|
|||
public HttpException(string message) : base(message) |
|||
{ |
|||
} |
|||
|
|||
public HttpException(string message, Exception inner) : base(message, inner) |
|||
{ |
|||
} |
|||
|
|||
public HttpException(HttpClientResponse response, T actualError) : base(response) |
|||
{ |
|||
ActualError = actualError; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 58232edbf38ad44249a2514728630186 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
namespace Unity.Services.Lobbies.Http |
|||
{ |
|||
public interface IError |
|||
{ |
|||
string Type { get; } |
|||
string Title { get; } |
|||
int? Status { get; } |
|||
int Code { get; } |
|||
string Detail { get; } |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 1da59228ebaaf46f597413704aba8f6a |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
using UnityEngine.Networking; |
|||
|
|||
namespace Unity.Services.Lobbies.Http |
|||
{ |
|||
public interface IHttpClient |
|||
{ |
|||
void Get(string url, Dictionary<string, string> headers, Action<HttpClientResponse> onCompleted, int requestTimeout = 10); |
|||
void Delete(string url, Dictionary<string, string> headers, Action<HttpClientResponse> onCompleted, int requestTimeout = 10); |
|||
void Post(string url, byte[] body, Dictionary<string, string> headers, Action<HttpClientResponse> onCompleted, int requestTimeout = 10); |
|||
void Put(string url, byte[] body, Dictionary<string, string> headers, Action<HttpClientResponse> onCompleted, int requestTimeout = 10); |
|||
void MakeRequest(string method, string url, byte[] body, Dictionary<string, string> headers, Action<HttpClientResponse> onCompleted, int requestTimeout = 10); |
|||
Task<HttpClientResponse> MakeRequestAsync(string method, string url, byte[] body, Dictionary<string, string> headers, int requestTimeout); |
|||
Task<HttpClientResponse> MakeRequestAsync(string method, string url, List<IMultipartFormSection> body, Dictionary<string, string> headers, int requestTimeout, string boundary = null); |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 0b093dfcc222c458cbf885b998b67d67 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using Newtonsoft.Json; |
|||
using Newtonsoft.Json.Converters; |
|||
using Newtonsoft.Json.Utilities; |
|||
using UnityEngine; |
|||
|
|||
namespace Unity.Services.Lobbies.Http |
|||
{ |
|||
internal static class JsonHelpers |
|||
{ |
|||
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSplashScreen)] |
|||
internal static void RegisterTypesForAOT() |
|||
{ |
|||
AotHelper.EnsureType<StringEnumConverter>(); |
|||
} |
|||
|
|||
internal static bool TryParseJson<T>(this string @this, out T result) |
|||
{ |
|||
var success = true; |
|||
var settings = new JsonSerializerSettings |
|||
{ |
|||
Error = (sender, args) => |
|||
{ |
|||
success = false; |
|||
args.ErrorContext.Handled = true; |
|||
}, |
|||
MissingMemberHandling = MissingMemberHandling.Ignore |
|||
}; |
|||
result = JsonConvert.DeserializeObject<T>(@this, settings); |
|||
return success; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 053cb354ae0a64ab491a3ef376706de8 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.IO; |
|||
using System.Text; |
|||
using Newtonsoft.Json; |
|||
using Unity.Services.Lobbies.Models; |
|||
|
|||
namespace Unity.Services.Lobbies.Http |
|||
{ |
|||
public static class ResponseHandler |
|||
{ |
|||
public static T TryDeserializeResponse<T>(HttpClientResponse response) |
|||
{ |
|||
var settings = new JsonSerializerSettings |
|||
{ |
|||
MissingMemberHandling = MissingMemberHandling.Ignore |
|||
}; |
|||
|
|||
return JsonConvert.DeserializeObject<T>(GetDeserializardJson(response.Data), settings); |
|||
} |
|||
|
|||
public static object TryDeserializeResponse(HttpClientResponse response, Type type) |
|||
{ |
|||
var settings = new JsonSerializerSettings |
|||
{ |
|||
MissingMemberHandling = MissingMemberHandling.Ignore |
|||
}; |
|||
|
|||
return JsonConvert.DeserializeObject(GetDeserializardJson(response.Data), type, settings); |
|||
} |
|||
|
|||
private static string GetDeserializardJson(byte[] data) |
|||
{ |
|||
return Encoding.UTF8.GetString(data); |
|||
} |
|||
|
|||
public static void HandleAsyncResponse(HttpClientResponse response, Dictionary<string, Type> statusCodeToTypeMap) |
|||
{ |
|||
if (statusCodeToTypeMap.ContainsKey(response.StatusCode.ToString())) |
|||
{ |
|||
Type responseType = statusCodeToTypeMap[response.StatusCode.ToString()]; |
|||
if (responseType != null && response.IsHttpError || response.IsNetworkError) |
|||
{ |
|||
if (typeof(IOneOf).IsAssignableFrom(responseType)) |
|||
{ |
|||
var instance = CreateOneOfException(response, responseType); |
|||
throw instance; |
|||
} |
|||
else |
|||
{ |
|||
var instance = CreateHttpException(response, responseType); |
|||
throw instance; |
|||
} |
|||
} |
|||
} |
|||
else |
|||
{ |
|||
throw new HttpException(response); |
|||
} |
|||
} |
|||
|
|||
private static HttpException CreateOneOfException(HttpClientResponse response, Type responseType) |
|||
{ |
|||
try |
|||
{ |
|||
var dataObject = ResponseHandler.TryDeserializeResponse(response, responseType); |
|||
return CreateHttpException(response, ((IOneOf) dataObject).Type); |
|||
} |
|||
catch (ArgumentException e) |
|||
{ |
|||
throw new DeserializationException(response, e.Message); |
|||
} |
|||
catch (MissingFieldException) |
|||
{ |
|||
throw new DeserializationException(response, |
|||
"Discriminator field not found in the parsed json response."); |
|||
} |
|||
catch (DeserializationException e) when (e.response == null) |
|||
{ |
|||
throw new DeserializationException(response, e.Message); |
|||
} |
|||
catch (DeserializationException) |
|||
{ |
|||
throw; |
|||
} |
|||
catch (Exception) |
|||
{ |
|||
throw new DeserializationException(response); |
|||
} |
|||
} |
|||
|
|||
private static HttpException CreateHttpException(HttpClientResponse response, Type responseType) |
|||
{ |
|||
Type exceptionType = typeof(HttpException<>); |
|||
var genericException = exceptionType.MakeGenericType(responseType); |
|||
|
|||
try |
|||
{ |
|||
if (responseType == typeof(System.IO.Stream)) |
|||
{ |
|||
var streamObject = (object)(response.Data == null ? new MemoryStream() : new MemoryStream(response.Data)); |
|||
var streamObjectInstance = Activator.CreateInstance(genericException, new object[] {response, streamObject}); |
|||
return (HttpException) streamObjectInstance; |
|||
} |
|||
|
|||
var dataObject = ResponseHandler.TryDeserializeResponse(response, responseType); |
|||
var instance = Activator.CreateInstance(genericException, new object[] {response, dataObject}); |
|||
return (HttpException) instance; |
|||
} |
|||
catch (ArgumentException e) |
|||
{ |
|||
throw new DeserializationException(response, e.Message); |
|||
} |
|||
catch (MissingFieldException) |
|||
{ |
|||
throw new DeserializationException(response, |
|||
"Discriminator field not found in the parsed json response."); |
|||
} |
|||
catch (DeserializationException e) when (e.response == null) |
|||
{ |
|||
throw new DeserializationException(response, e.Message); |
|||
} |
|||
catch (DeserializationException) |
|||
{ |
|||
throw; |
|||
} |
|||
catch (Exception) |
|||
{ |
|||
throw new DeserializationException(response); |
|||
} |
|||
} |
|||
|
|||
public static T HandleAsyncResponse<T>(HttpClientResponse response, Dictionary<string, Type> statusCodeToTypeMap) where T : class |
|||
{ |
|||
HandleAsyncResponse(response, statusCodeToTypeMap); |
|||
|
|||
try |
|||
{ |
|||
if (statusCodeToTypeMap[response.StatusCode.ToString()] == typeof(System.IO.Stream)) |
|||
{ |
|||
return (response.Data == null ? new MemoryStream() : new MemoryStream(response.Data)) as T; |
|||
} |
|||
return ResponseHandler.TryDeserializeResponse<T>(response); |
|||
} |
|||
catch (ArgumentException e) |
|||
{ |
|||
throw new DeserializationException(response, e.Message); |
|||
} |
|||
catch (MissingFieldException) |
|||
{ |
|||
throw new DeserializationException(response, |
|||
"Discriminator field not found in the parsed json response."); |
|||
} |
|||
catch (DeserializationException e) when (e.response == null) |
|||
{ |
|||
throw new DeserializationException(response, e.Message); |
|||
} |
|||
catch (DeserializationException) |
|||
{ |
|||
throw; |
|||
} |
|||
catch (Exception) |
|||
{ |
|||
throw new DeserializationException(response); |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: d4ffd438c7fc249c3b17e41609970c50 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using Unity.Services.Lobbies.Http; |
|||
|
|||
namespace Unity.Services.Lobbies |
|||
{ |
|||
public class Response { |
|||
public Dictionary<string, string> Headers { get; } |
|||
public long Status { get; set; } |
|||
|
|||
public Response(HttpClientResponse httpResponse) |
|||
{ |
|||
this.Headers = httpResponse.Headers; |
|||
this.Status = httpResponse.StatusCode; |
|||
} |
|||
} |
|||
|
|||
public class Response<T> : Response |
|||
{ |
|||
public T Result { get; } |
|||
|
|||
public Response(HttpClientResponse httpResponse, T result): base(httpResponse) |
|||
{ |
|||
this.Result = result; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 18ede7f294fc742fe93636c4e007a689 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Runtime.CompilerServices; |
|||
using System.Threading.Tasks; |
|||
using UnityEngine.Networking; |
|||
|
|||
namespace Unity.Services.Lobbies.Http |
|||
{ |
|||
public static class UnityWebRequestHelpers |
|||
{ |
|||
public static TaskAwaiter<HttpClientResponse> GetAwaiter(this UnityWebRequestAsyncOperation asyncOp) |
|||
{ |
|||
var tcs = new TaskCompletionSource<HttpClientResponse>(); |
|||
|
|||
asyncOp.completed += obj => |
|||
{ |
|||
var result = CreateHttpClientResponse((UnityWebRequestAsyncOperation) obj); |
|||
tcs.SetResult(result); |
|||
}; |
|||
return tcs.Task.GetAwaiter(); |
|||
} |
|||
|
|||
internal static HttpClientResponse CreateHttpClientResponse(UnityWebRequestAsyncOperation unityResponse) |
|||
{ |
|||
var response = unityResponse.webRequest; |
|||
var result = new HttpClientResponse( |
|||
response.GetResponseHeaders(), |
|||
response.responseCode, |
|||
#if UNITY_2020_1_OR_NEWER
|
|||
response.result == UnityWebRequest.Result.ProtocolError, |
|||
response.result == UnityWebRequest.Result.ConnectionError, |
|||
#else
|
|||
response.isHttpError, |
|||
response.isNetworkError, |
|||
#endif
|
|||
response.downloadHandler.data, |
|||
response.error); |
|||
return result; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: dfc22921885c841cdbbd0f2ecac02c55 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using Unity.Services.Lobbies.Apis; |
|||
|
|||
|
|||
namespace Unity.Services.Lobbies |
|||
{ |
|||
public static class LobbyService |
|||
{ |
|||
/// <summary>
|
|||
/// Static accessor for LobbyApi methods.
|
|||
/// </summary>
|
|||
public static ILobbyApiClient LobbyApiClient { get; internal set; } |
|||
|
|||
public static Configuration Configuration = new Configuration("https://lobby.cloud.unity3d.com/v1", 10, 4, null); |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: e252044ff978b47cc8c06ec6e59b31bf |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using UnityEngine; |
|||
using System.Threading.Tasks; |
|||
|
|||
using Unity.Services.Lobbies.Apis; |
|||
|
|||
using Unity.Services.Lobbies.Http; |
|||
using Unity.Services.Lobbies.Scheduler; |
|||
using TaskScheduler = Unity.Services.Lobbies.Scheduler.TaskScheduler; |
|||
using Unity.Services.Core; |
|||
using Unity.Services.Authentication; |
|||
|
|||
namespace Unity.Services.Lobbies |
|||
{ |
|||
internal class LobbyServiceProvider : IInitializablePackage |
|||
{ |
|||
private static GameObject _gameObjectFactory; |
|||
|
|||
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)] |
|||
static void Register() |
|||
{ |
|||
// Pass an instance of this class to Core
|
|||
var generatedPackageRegistry = |
|||
CoreRegistry.Instance.RegisterPackage(new LobbyServiceProvider()); |
|||
// And specify what components it requires, or provides.
|
|||
generatedPackageRegistry.DependsOn<IAccessToken>(); |
|||
; |
|||
} |
|||
|
|||
public Task Initialize(CoreRegistry registry) |
|||
{ |
|||
_gameObjectFactory = GameObjectFactory.CreateCoreSdkGameObject(); |
|||
var scheduler = _gameObjectFactory.GetComponent<TaskScheduler>(); |
|||
var httpClient = new HttpClient(scheduler); |
|||
|
|||
var accessTokenLobbyApi = registry.GetServiceComponent<IAccessToken>(); |
|||
|
|||
if (accessTokenLobbyApi != null) |
|||
{ |
|||
LobbyService.LobbyApiClient = new LobbyApiClient(httpClient, scheduler, accessTokenLobbyApi); |
|||
} |
|||
|
|||
return Task.CompletedTask; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 812e6cc46cfdb48b5b4bf47b8cb1bd49 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 1e4788f1c450f4bca8d1ffa54541afd2 |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using UnityEngine.Scripting; |
|||
using System.Runtime.Serialization; |
|||
using Newtonsoft.Json; |
|||
using Newtonsoft.Json.Converters; |
|||
|
|||
|
|||
|
|||
namespace Unity.Services.Lobbies.Models |
|||
{ |
|||
/// <summary>
|
|||
/// The body of a Create Lobby request.
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[DataContract(Name = "CreateRequest")] |
|||
public class CreateRequest |
|||
{ |
|||
/// <summary>
|
|||
/// The body of a Create Lobby request.
|
|||
/// </summary>
|
|||
/// <param name="name">The name of the lobby that should be displayed to users. All whitespace will be trimmed from name.</param>
|
|||
/// <param name="maxPlayers">The maximum number of players allowed in the lobby.</param>
|
|||
/// <param name="isPrivate">Indicates whether or not the lobby is publicly visible and will show up in query results. If the lobby is not publicly visible, the creator can share the `lobbyCode` with other users who can use it to join this lobby.</param>
|
|||
/// <param name="player">player param</param>
|
|||
/// <param name="data">Custom game-specific properties that apply to the lobby (e.g. `mapName` or `gameType`).</param>
|
|||
[Preserve] |
|||
public CreateRequest(string name, int maxPlayers, bool? isPrivate = null, Player player = default(Player), Dictionary<string, DataObject> data = null) |
|||
{ |
|||
Name = name; |
|||
MaxPlayers = maxPlayers; |
|||
IsPrivate = isPrivate; |
|||
Player = player; |
|||
Data = data; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// The name of the lobby that should be displayed to users. All whitespace will be trimmed from name.
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[DataMember(Name = "name", IsRequired = true, EmitDefaultValue = true)] |
|||
public string Name{ get; } |
|||
|
|||
/// <summary>
|
|||
/// The maximum number of players allowed in the lobby.
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[DataMember(Name = "maxPlayers", IsRequired = true, EmitDefaultValue = true)] |
|||
public int MaxPlayers{ get; } |
|||
|
|||
/// <summary>
|
|||
/// Indicates whether or not the lobby is publicly visible and will show up in query results. If the lobby is not publicly visible, the creator can share the `lobbyCode` with other users who can use it to join this lobby.
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[DataMember(Name = "isPrivate", EmitDefaultValue = true)] |
|||
public bool? IsPrivate{ get; } |
|||
|
|||
/// <summary>
|
|||
/// player param
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[DataMember(Name = "player", EmitDefaultValue = false)] |
|||
public Player Player{ get; } |
|||
|
|||
/// <summary>
|
|||
/// Custom game-specific properties that apply to the lobby (e.g. `mapName` or `gameType`).
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[DataMember(Name = "data", EmitDefaultValue = false)] |
|||
public Dictionary<string, DataObject> Data{ get; } |
|||
|
|||
} |
|||
} |
|||
|
|
|||
fileFormatVersion: 2 |
|||
guid: 9483a3c0aae5e49abb35865aa4e0b834 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using UnityEngine.Scripting; |
|||
using System.Runtime.Serialization; |
|||
using Newtonsoft.Json; |
|||
using Newtonsoft.Json.Converters; |
|||
|
|||
|
|||
|
|||
namespace Unity.Services.Lobbies.Models |
|||
{ |
|||
/// <summary>
|
|||
/// Custom data property for a lobby.
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[DataContract(Name = "DataObject")] |
|||
public class DataObject |
|||
{ |
|||
/// <summary>
|
|||
/// Custom data property for a lobby.
|
|||
/// </summary>
|
|||
/// <param name="visibility">Indicates for whom the property should be visible. If `public`, the property will be visible to everyone and will be included in query results. If `member` the data will only be visible to users who are members of the lobby (i.e. those who have successfully joined). If `private`, the metadata will only be visible to the host.</param>
|
|||
/// <param name="value">The value of the custom property. This property can be set to null or empty string. If this property is indexed (by setting the `index` field) then the length of the value must be less than 128 bytes.</param>
|
|||
/// <param name="index">The name of the column to index this property value under, either `S#` for strings or `N#` for numeric values. If an index is specified on a property, then you can use that index name in a `QueryFilter` to filter results by that property. If You will not be prevented from indexing multiple objects having properties different with names but the same the same index, but you will likely receive unexpected results from a query.</param>
|
|||
[Preserve] |
|||
public DataObject(VisibilityOptions visibility, string value = null, IndexOptions index = default) |
|||
{ |
|||
Visibility = visibility; |
|||
Value = value; |
|||
Index = index; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Indicates for whom the property should be visible. If `public`, the property will be visible to everyone and will be included in query results. If `member` the data will only be visible to users who are members of the lobby (i.e. those who have successfully joined). If `private`, the metadata will only be visible to the host.
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[JsonConverter(typeof(StringEnumConverter))] |
|||
[DataMember(Name = "visibility", IsRequired = true, EmitDefaultValue = true)] |
|||
public VisibilityOptions Visibility{ get; } |
|||
|
|||
/// <summary>
|
|||
/// The value of the custom property. This property can be set to null or empty string. If this property is indexed (by setting the `index` field) then the length of the value must be less than 128 bytes.
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[DataMember(Name = "value", EmitDefaultValue = false)] |
|||
public string Value{ get; } |
|||
|
|||
/// <summary>
|
|||
/// The name of the column to index this property value under, either `S#` for strings or `N#` for numeric values. If an index is specified on a property, then you can use that index name in a `QueryFilter` to filter results by that property. If You will not be prevented from indexing multiple objects having properties different with names but the same the same index, but you will likely receive unexpected results from a query.
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[JsonConverter(typeof(StringEnumConverter))] |
|||
[DataMember(Name = "index", EmitDefaultValue = false)] |
|||
public IndexOptions Index{ get; } |
|||
|
|||
|
|||
/// <summary>
|
|||
/// Indicates for whom the property should be visible. If `public`, the property will be visible to everyone and will be included in query results. If `member` the data will only be visible to users who are members of the lobby (i.e. those who have successfully joined). If `private`, the metadata will only be visible to the host.
|
|||
/// </summary>
|
|||
/// <value>Indicates for whom the property should be visible. If `public`, the property will be visible to everyone and will be included in query results. If `member` the data will only be visible to users who are members of the lobby (i.e. those who have successfully joined). If `private`, the metadata will only be visible to the host.</value>
|
|||
[JsonConverter(typeof(StringEnumConverter))] |
|||
public enum VisibilityOptions |
|||
{ |
|||
/// <summary>
|
|||
/// Enum Public for value: public
|
|||
/// </summary>
|
|||
[EnumMember(Value = "public")] |
|||
Public = 1, |
|||
|
|||
/// <summary>
|
|||
/// Enum Member for value: member
|
|||
/// </summary>
|
|||
[EnumMember(Value = "member")] |
|||
Member = 2, |
|||
|
|||
/// <summary>
|
|||
/// Enum Private for value: private
|
|||
/// </summary>
|
|||
[EnumMember(Value = "private")] |
|||
Private = 3 |
|||
|
|||
} |
|||
|
|||
|
|||
/// <summary>
|
|||
/// The name of the column to index this property value under, either `S#` for strings or `N#` for numeric values. If an index is specified on a property, then you can use that index name in a `QueryFilter` to filter results by that property. If You will not be prevented from indexing multiple objects having properties different with names but the same the same index, but you will likely receive unexpected results from a query.
|
|||
/// </summary>
|
|||
/// <value>The name of the column to index this property value under, either `S#` for strings or `N#` for numeric values. If an index is specified on a property, then you can use that index name in a `QueryFilter` to filter results by that property. If You will not be prevented from indexing multiple objects having properties different with names but the same the same index, but you will likely receive unexpected results from a query.</value>
|
|||
[JsonConverter(typeof(StringEnumConverter))] |
|||
public enum IndexOptions |
|||
{ |
|||
/// <summary>
|
|||
/// Enum S1 for value: S1
|
|||
/// </summary>
|
|||
[EnumMember(Value = "S1")] |
|||
S1 = 1, |
|||
|
|||
/// <summary>
|
|||
/// Enum S2 for value: S2
|
|||
/// </summary>
|
|||
[EnumMember(Value = "S2")] |
|||
S2 = 2, |
|||
|
|||
/// <summary>
|
|||
/// Enum S3 for value: S3
|
|||
/// </summary>
|
|||
[EnumMember(Value = "S3")] |
|||
S3 = 3, |
|||
|
|||
/// <summary>
|
|||
/// Enum S4 for value: S4
|
|||
/// </summary>
|
|||
[EnumMember(Value = "S4")] |
|||
S4 = 4, |
|||
|
|||
/// <summary>
|
|||
/// Enum S5 for value: S5
|
|||
/// </summary>
|
|||
[EnumMember(Value = "S5")] |
|||
S5 = 5, |
|||
|
|||
/// <summary>
|
|||
/// Enum N1 for value: N1
|
|||
/// </summary>
|
|||
[EnumMember(Value = "N1")] |
|||
N1 = 6, |
|||
|
|||
/// <summary>
|
|||
/// Enum N2 for value: N2
|
|||
/// </summary>
|
|||
[EnumMember(Value = "N2")] |
|||
N2 = 7, |
|||
|
|||
/// <summary>
|
|||
/// Enum N3 for value: N3
|
|||
/// </summary>
|
|||
[EnumMember(Value = "N3")] |
|||
N3 = 8, |
|||
|
|||
/// <summary>
|
|||
/// Enum N4 for value: N4
|
|||
/// </summary>
|
|||
[EnumMember(Value = "N4")] |
|||
N4 = 9, |
|||
|
|||
/// <summary>
|
|||
/// Enum N5 for value: N5
|
|||
/// </summary>
|
|||
[EnumMember(Value = "N5")] |
|||
N5 = 10 |
|||
|
|||
} |
|||
|
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 62d95d51b6b604296bec8133022e88ae |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using UnityEngine.Scripting; |
|||
using System.Runtime.Serialization; |
|||
using Newtonsoft.Json; |
|||
using Newtonsoft.Json.Converters; |
|||
|
|||
|
|||
|
|||
namespace Unity.Services.Lobbies.Models |
|||
{ |
|||
/// <summary>
|
|||
/// Additional detail about an error. This may include detailed validation failure messages, debugging information, troubleshooting steps, or more.
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[DataContract(Name = "Detail")] |
|||
public class Detail |
|||
{ |
|||
/// <summary>
|
|||
/// Additional detail about an error. This may include detailed validation failure messages, debugging information, troubleshooting steps, or more.
|
|||
/// </summary>
|
|||
/// <param name="errorType">errorType param</param>
|
|||
/// <param name="message">message param</param>
|
|||
[Preserve] |
|||
public Detail(string errorType = default(string), string message = default(string)) |
|||
{ |
|||
ErrorType = errorType; |
|||
Message = message; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// errorType param
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[DataMember(Name = "errorType", EmitDefaultValue = false)] |
|||
public string ErrorType{ get; } |
|||
|
|||
/// <summary>
|
|||
/// message param
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[DataMember(Name = "message", EmitDefaultValue = false)] |
|||
public string Message{ get; } |
|||
|
|||
} |
|||
} |
|||
|
|
|||
fileFormatVersion: 2 |
|||
guid: d5dd79820f9e34f8f9a67c52fb75585f |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using UnityEngine.Scripting; |
|||
using System.Runtime.Serialization; |
|||
using Newtonsoft.Json; |
|||
using Newtonsoft.Json.Converters; |
|||
|
|||
|
|||
|
|||
namespace Unity.Services.Lobbies.Models |
|||
{ |
|||
/// <summary>
|
|||
/// The body that will be returned for any failing request. We are using the [RFC 7807 Error Format](https://www.rfc-editor.org/rfc/rfc7807.html#section-3.1).
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[DataContract(Name = "ErrorStatus")] |
|||
public class ErrorStatus |
|||
{ |
|||
/// <summary>
|
|||
/// The body that will be returned for any failing request. We are using the [RFC 7807 Error Format](https://www.rfc-editor.org/rfc/rfc7807.html#section-3.1).
|
|||
/// </summary>
|
|||
/// <param name="status">status param</param>
|
|||
/// <param name="title">title param</param>
|
|||
/// <param name="details">details param</param>
|
|||
[Preserve] |
|||
public ErrorStatus(int status = default(int), string title = default(string), List<Detail> details = default(List<Detail>)) |
|||
{ |
|||
Status = status; |
|||
Title = title; |
|||
Details = details; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// status param
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[DataMember(Name = "status", EmitDefaultValue = false)] |
|||
public int Status{ get; } |
|||
|
|||
/// <summary>
|
|||
/// title param
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[DataMember(Name = "title", EmitDefaultValue = false)] |
|||
public string Title{ get; } |
|||
|
|||
/// <summary>
|
|||
/// details param
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[DataMember(Name = "details", EmitDefaultValue = false)] |
|||
public List<Detail> Details{ get; } |
|||
|
|||
} |
|||
} |
|||
|
|
|||
fileFormatVersion: 2 |
|||
guid: a24b83f22e6c34e7997f74c83582802b |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using UnityEngine.Scripting; |
|||
using System.Runtime.Serialization; |
|||
using Newtonsoft.Json; |
|||
using Newtonsoft.Json.Converters; |
|||
|
|||
|
|||
|
|||
namespace Unity.Services.Lobbies.Models |
|||
{ |
|||
/// <summary>
|
|||
/// The body of a Join Lobby request using lobby code.
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[DataContract(Name = "JoinByCodeRequest")] |
|||
public class JoinByCodeRequest |
|||
{ |
|||
/// <summary>
|
|||
/// The body of a Join Lobby request using lobby code.
|
|||
/// </summary>
|
|||
/// <param name="lobbyCode">The lobby code of the lobby the join. Mutually exclusive with `id`. This is used to join a private lobby where the lobby code was shared to other users manually.</param>
|
|||
/// <param name="player">player param</param>
|
|||
[Preserve] |
|||
public JoinByCodeRequest(string lobbyCode, Player player = default(Player)) |
|||
{ |
|||
LobbyCode = lobbyCode; |
|||
Player = player; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// The lobby code of the lobby the join. Mutually exclusive with `id`. This is used to join a private lobby where the lobby code was shared to other users manually.
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[DataMember(Name = "lobbyCode", IsRequired = true, EmitDefaultValue = true)] |
|||
public string LobbyCode{ get; } |
|||
|
|||
/// <summary>
|
|||
/// player param
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[DataMember(Name = "player", EmitDefaultValue = false)] |
|||
public Player Player{ get; } |
|||
|
|||
} |
|||
} |
|||
|
|
|||
fileFormatVersion: 2 |
|||
guid: 4e5ff66d4531a26408b9ec6963068074 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using UnityEngine.Scripting; |
|||
using System.Runtime.Serialization; |
|||
using Newtonsoft.Json; |
|||
using Newtonsoft.Json.Converters; |
|||
|
|||
|
|||
|
|||
namespace Unity.Services.Lobbies.Models |
|||
{ |
|||
/// <summary>
|
|||
/// The body of a Join Lobby request.
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[DataContract(Name = "JoinRequest")] |
|||
public class JoinRequest |
|||
{ |
|||
/// <summary>
|
|||
/// The body of a Join Lobby request.
|
|||
/// </summary>
|
|||
/// <param name="id">The id of the lobby to join. Mutually exclusive with `lobbyCode`. This is used to join a public lobby that has been discovered via a Query request.</param>
|
|||
/// <param name="lobbyCode">The lobby code of the lobby the join. Mutually exclusive with `id`. This is used to join a private lobby where the lobby code was shared to other users manually.</param>
|
|||
/// <param name="player">player param</param>
|
|||
[Preserve] |
|||
public JoinRequest(string id = null, string lobbyCode = null, Player player = default(Player)) |
|||
{ |
|||
Id = id; |
|||
LobbyCode = lobbyCode; |
|||
Player = player; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// The id of the lobby to join. Mutually exclusive with `lobbyCode`. This is used to join a public lobby that has been discovered via a Query request.
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[DataMember(Name = "id", EmitDefaultValue = false)] |
|||
public string Id{ get; } |
|||
|
|||
/// <summary>
|
|||
/// The lobby code of the lobby the join. Mutually exclusive with `id`. This is used to join a private lobby where the lobby code was shared to other users manually.
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[DataMember(Name = "lobbyCode", EmitDefaultValue = false)] |
|||
public string LobbyCode{ get; } |
|||
|
|||
/// <summary>
|
|||
/// player param
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[DataMember(Name = "player", EmitDefaultValue = false)] |
|||
public Player Player{ get; } |
|||
|
|||
} |
|||
} |
|||
|
|
|||
fileFormatVersion: 2 |
|||
guid: 0084656e5869a476a83642381819f68e |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using UnityEngine.Scripting; |
|||
using System.Runtime.Serialization; |
|||
using Newtonsoft.Json; |
|||
using Newtonsoft.Json.Converters; |
|||
|
|||
|
|||
|
|||
namespace Unity.Services.Lobbies.Models |
|||
{ |
|||
/// <summary>
|
|||
/// JoinRequestOneOf model
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[DataContract(Name = "JoinRequestOneOf")] |
|||
public class JoinRequestOneOf |
|||
{ |
|||
/// <summary>
|
|||
/// JoinRequestOneOf model
|
|||
/// </summary>
|
|||
[Preserve] |
|||
public JoinRequestOneOf() |
|||
{ |
|||
} |
|||
|
|||
|
|||
|
|||
} |
|||
} |
|||
|
|
|||
fileFormatVersion: 2 |
|||
guid: 690ae8354e20447fc977b3312e394cab |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using UnityEngine.Scripting; |
|||
using System.Runtime.Serialization; |
|||
using Newtonsoft.Json; |
|||
using Newtonsoft.Json.Converters; |
|||
|
|||
|
|||
|
|||
namespace Unity.Services.Lobbies.Models |
|||
{ |
|||
/// <summary>
|
|||
/// Data about an individual lobby.
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[DataContract(Name = "Lobby")] |
|||
public class Lobby |
|||
{ |
|||
/// <summary>
|
|||
/// Data about an individual lobby.
|
|||
/// </summary>
|
|||
/// <param name="id">id param</param>
|
|||
/// <param name="lobbyCode">A short code that be used to join a lobby. This is only visible to lobby members. Typically this is displayed to the user so they can share it with other players out of game. Users with the code can join the lobby even when it is private.</param>
|
|||
/// <param name="upid">The Unity project ID of the game.</param>
|
|||
/// <param name="name">The name of the lobby. Typically this shown in game UI to represent the lobby.</param>
|
|||
/// <param name="maxPlayers">The maximum number of players that can be members of the lobby.</param>
|
|||
/// <param name="availableSlots">The number of remaining open slots for players before the lobby becomes full.</param>
|
|||
/// <param name="isPrivate">Whether the lobby is private or not. Private lobbies do not appear in query results.</param>
|
|||
/// <param name="players">The members of the lobby.</param>
|
|||
/// <param name="data">Properties of the lobby set by the host.</param>
|
|||
/// <param name="hostId">The ID of the player that is the lobby host.</param>
|
|||
/// <param name="created">When the lobby was created. The timestamp is in UTC and conforms to ISO 8601.</param>
|
|||
/// <param name="lastUpdated">When the lobby was last updated. The timestamp is in UTC and conforms to ISO 8601.</param>
|
|||
[Preserve] |
|||
public Lobby(string id = default(string), string lobbyCode = null, string upid = default(string), string name = null, int maxPlayers = default(int), int availableSlots = default(int), bool isPrivate = default(bool), List<Player> players = default(List<Player>), Dictionary<string, DataObject> data = null, string hostId = default(string), DateTime created = default(DateTime), DateTime lastUpdated = default(DateTime)) |
|||
{ |
|||
Id = id; |
|||
LobbyCode = lobbyCode; |
|||
Upid = upid; |
|||
Name = name; |
|||
MaxPlayers = maxPlayers; |
|||
AvailableSlots = availableSlots; |
|||
IsPrivate = isPrivate; |
|||
Players = players; |
|||
Data = data; |
|||
HostId = hostId; |
|||
Created = created; |
|||
LastUpdated = lastUpdated; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// id param
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[DataMember(Name = "id", EmitDefaultValue = false)] |
|||
public string Id{ get; } |
|||
|
|||
/// <summary>
|
|||
/// A short code that be used to join a lobby. This is only visible to lobby members. Typically this is displayed to the user so they can share it with other players out of game. Users with the code can join the lobby even when it is private.
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[DataMember(Name = "lobbyCode", EmitDefaultValue = false)] |
|||
public string LobbyCode{ get; } |
|||
|
|||
/// <summary>
|
|||
/// The Unity project ID of the game.
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[DataMember(Name = "upid", EmitDefaultValue = false)] |
|||
public string Upid{ get; } |
|||
|
|||
/// <summary>
|
|||
/// The name of the lobby. Typically this shown in game UI to represent the lobby.
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[DataMember(Name = "name", EmitDefaultValue = false)] |
|||
public string Name{ get; } |
|||
|
|||
/// <summary>
|
|||
/// The maximum number of players that can be members of the lobby.
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[DataMember(Name = "maxPlayers", EmitDefaultValue = false)] |
|||
public int MaxPlayers{ get; } |
|||
|
|||
/// <summary>
|
|||
/// The number of remaining open slots for players before the lobby becomes full.
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[DataMember(Name = "availableSlots", EmitDefaultValue = false)] |
|||
public int AvailableSlots{ get; } |
|||
|
|||
/// <summary>
|
|||
/// Whether the lobby is private or not. Private lobbies do not appear in query results.
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[DataMember(Name = "isPrivate", EmitDefaultValue = true)] |
|||
public bool IsPrivate{ get; } |
|||
|
|||
/// <summary>
|
|||
/// The members of the lobby.
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[DataMember(Name = "players", EmitDefaultValue = false)] |
|||
public List<Player> Players{ get; } |
|||
|
|||
/// <summary>
|
|||
/// Properties of the lobby set by the host.
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[DataMember(Name = "data", EmitDefaultValue = false)] |
|||
public Dictionary<string, DataObject> Data{ get; } |
|||
|
|||
/// <summary>
|
|||
/// The ID of the player that is the lobby host.
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[DataMember(Name = "hostId", EmitDefaultValue = false)] |
|||
public string HostId{ get; } |
|||
|
|||
/// <summary>
|
|||
/// When the lobby was created. The timestamp is in UTC and conforms to ISO 8601.
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[DataMember(Name = "created", EmitDefaultValue = false)] |
|||
public DateTime Created{ get; } |
|||
|
|||
/// <summary>
|
|||
/// When the lobby was last updated. The timestamp is in UTC and conforms to ISO 8601.
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[DataMember(Name = "lastUpdated", EmitDefaultValue = false)] |
|||
public DateTime LastUpdated{ get; } |
|||
|
|||
} |
|||
} |
|||
|
|
|||
fileFormatVersion: 2 |
|||
guid: d514f234f15fa4c27b49e4e258e19a60 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
|
|||
namespace Unity.Services.Lobbies.Models |
|||
{ |
|||
public interface IOneOf |
|||
{ |
|||
Type Type { get; } |
|||
object Value { get; } |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 1286c7fd235c44e8689081ade5dc4e23 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using UnityEngine.Scripting; |
|||
using System.Runtime.Serialization; |
|||
using Newtonsoft.Json; |
|||
using Newtonsoft.Json.Converters; |
|||
|
|||
|
|||
|
|||
namespace Unity.Services.Lobbies.Models |
|||
{ |
|||
/// <summary>
|
|||
/// Information about a specific player creating, joining, or already in a lobby.
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[DataContract(Name = "Player")] |
|||
public class Player |
|||
{ |
|||
/// <summary>
|
|||
/// Information about a specific player creating, joining, or already in a lobby.
|
|||
/// </summary>
|
|||
/// <param name="id">The unique identifier for the player. If not provided for a create or join request it will be set to the id of the caller.</param>
|
|||
/// <param name="connectionInfo">(TBD) Connection information for connecting to a relay with this player.</param>
|
|||
/// <param name="data">Custom game-specific properties that apply to an individual player (e.g. `role` or `skill`).</param>
|
|||
/// <param name="allocationId">An id that associates this player in this lobby with a persistent connection. When a disconnect notification is recevied, this value is used to identify the associated player in a lobby to mark them as disconnected.</param>
|
|||
/// <param name="joined">The time at which the player joined the lobby.</param>
|
|||
/// <param name="lastUpdated">The last time the metadata for this player was updated.</param>
|
|||
[Preserve] |
|||
public Player(string id = null, string connectionInfo = null, Dictionary<string, PlayerDataObject> data = null, string allocationId = null, DateTime joined = default(DateTime), DateTime lastUpdated = default(DateTime)) |
|||
{ |
|||
Id = id; |
|||
ConnectionInfo = connectionInfo; |
|||
Data = data; |
|||
AllocationId = allocationId; |
|||
Joined = joined; |
|||
LastUpdated = lastUpdated; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// The unique identifier for the player. If not provided for a create or join request it will be set to the id of the caller.
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[DataMember(Name = "id", EmitDefaultValue = false)] |
|||
public string Id{ get; } |
|||
|
|||
/// <summary>
|
|||
/// (TBD) Connection information for connecting to a relay with this player.
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[DataMember(Name = "connectionInfo", EmitDefaultValue = false)] |
|||
public string ConnectionInfo{ get; } |
|||
|
|||
/// <summary>
|
|||
/// Custom game-specific properties that apply to an individual player (e.g. `role` or `skill`).
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[DataMember(Name = "data", EmitDefaultValue = false)] |
|||
public Dictionary<string, PlayerDataObject> Data{ get; } |
|||
|
|||
/// <summary>
|
|||
/// An id that associates this player in this lobby with a persistent connection. When a disconnect notification is recevied, this value is used to identify the associated player in a lobby to mark them as disconnected.
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[DataMember(Name = "allocationId", EmitDefaultValue = false)] |
|||
public string AllocationId{ get; } |
|||
|
|||
/// <summary>
|
|||
/// The time at which the player joined the lobby.
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[DataMember(Name = "joined", EmitDefaultValue = false)] |
|||
public DateTime Joined{ get; } |
|||
|
|||
/// <summary>
|
|||
/// The last time the metadata for this player was updated.
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[DataMember(Name = "lastUpdated", EmitDefaultValue = false)] |
|||
public DateTime LastUpdated{ get; } |
|||
|
|||
} |
|||
} |
|||
|
|
|||
fileFormatVersion: 2 |
|||
guid: 3101ac2026071440c8600b70a6ca23d3 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using UnityEngine.Scripting; |
|||
using System.Runtime.Serialization; |
|||
using Newtonsoft.Json; |
|||
using Newtonsoft.Json.Converters; |
|||
|
|||
|
|||
|
|||
namespace Unity.Services.Lobbies.Models |
|||
{ |
|||
/// <summary>
|
|||
/// Custom data property for a player.
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[DataContract(Name = "PlayerDataObject")] |
|||
public class PlayerDataObject |
|||
{ |
|||
/// <summary>
|
|||
/// Custom data property for a player.
|
|||
/// </summary>
|
|||
/// <param name="visibility">Indicates for whom the property should be visible. If `public`, the property will be visible to everyone and will be included in query results. If `member` the data will only be visible to users who are members of the lobby (i.e. those who have successfully joined). If `private`, the metadata will only be visible to the the player.</param>
|
|||
/// <param name="value">The value of the custom property. This property can be set to null or empty string.</param>
|
|||
[Preserve] |
|||
public PlayerDataObject(VisibilityOptions visibility, string value = null) |
|||
{ |
|||
Visibility = visibility; |
|||
Value = value; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Indicates for whom the property should be visible. If `public`, the property will be visible to everyone and will be included in query results. If `member` the data will only be visible to users who are members of the lobby (i.e. those who have successfully joined). If `private`, the metadata will only be visible to the the player.
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[JsonConverter(typeof(StringEnumConverter))] |
|||
[DataMember(Name = "visibility", IsRequired = true, EmitDefaultValue = true)] |
|||
public VisibilityOptions Visibility{ get; } |
|||
|
|||
/// <summary>
|
|||
/// The value of the custom property. This property can be set to null or empty string.
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[DataMember(Name = "value", EmitDefaultValue = false)] |
|||
public string Value{ get; } |
|||
|
|||
|
|||
/// <summary>
|
|||
/// Indicates for whom the property should be visible. If `public`, the property will be visible to everyone and will be included in query results. If `member` the data will only be visible to users who are members of the lobby (i.e. those who have successfully joined). If `private`, the metadata will only be visible to the the player.
|
|||
/// </summary>
|
|||
/// <value>Indicates for whom the property should be visible. If `public`, the property will be visible to everyone and will be included in query results. If `member` the data will only be visible to users who are members of the lobby (i.e. those who have successfully joined). If `private`, the metadata will only be visible to the the player.</value>
|
|||
[JsonConverter(typeof(StringEnumConverter))] |
|||
public enum VisibilityOptions |
|||
{ |
|||
/// <summary>
|
|||
/// Enum Public for value: public
|
|||
/// </summary>
|
|||
[EnumMember(Value = "public")] |
|||
Public = 1, |
|||
|
|||
/// <summary>
|
|||
/// Enum Member for value: member
|
|||
/// </summary>
|
|||
[EnumMember(Value = "member")] |
|||
Member = 2, |
|||
|
|||
/// <summary>
|
|||
/// Enum Private for value: private
|
|||
/// </summary>
|
|||
[EnumMember(Value = "private")] |
|||
Private = 3 |
|||
|
|||
} |
|||
|
|||
} |
|||
} |
|||
|
|
|||
fileFormatVersion: 2 |
|||
guid: 4b3471f8a040c47eab149048fa65e3f4 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using UnityEngine.Scripting; |
|||
using System.Runtime.Serialization; |
|||
using Newtonsoft.Json; |
|||
using Newtonsoft.Json.Converters; |
|||
|
|||
|
|||
|
|||
namespace Unity.Services.Lobbies.Models |
|||
{ |
|||
/// <summary>
|
|||
/// The body of an Update Player Data request.
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[DataContract(Name = "PlayerUpdateRequest")] |
|||
public class PlayerUpdateRequest |
|||
{ |
|||
/// <summary>
|
|||
/// The body of an Update Player Data request.
|
|||
/// </summary>
|
|||
/// <param name="connectionInfo">(TBD) Connection information for connecting to a relay with this player.</param>
|
|||
/// <param name="data">Custom game-specific properties to add, update, or remove from the player (e.g. `role` or `skill`). To remove an existing property, include it in `data` but set the property object to `null`. To update the value to `null`, set the `value` property of the object to `null`.</param>
|
|||
/// <param name="allocationId">An id that associates this player in this lobby with a persistent connection. When a disconnect notification is recevied, this value is used to identify the associated player in a lobby to mark them as disconnected.</param>
|
|||
[Preserve] |
|||
public PlayerUpdateRequest(string connectionInfo = null, Dictionary<string, PlayerDataObject> data = null, string allocationId = null) |
|||
{ |
|||
ConnectionInfo = connectionInfo; |
|||
Data = data; |
|||
AllocationId = allocationId; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// (TBD) Connection information for connecting to a relay with this player.
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[DataMember(Name = "connectionInfo", EmitDefaultValue = false)] |
|||
public string ConnectionInfo{ get; } |
|||
|
|||
/// <summary>
|
|||
/// Custom game-specific properties to add, update, or remove from the player (e.g. `role` or `skill`). To remove an existing property, include it in `data` but set the property object to `null`. To update the value to `null`, set the `value` property of the object to `null`.
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[DataMember(Name = "data", EmitDefaultValue = false)] |
|||
public Dictionary<string, PlayerDataObject> Data{ get; } |
|||
|
|||
/// <summary>
|
|||
/// An id that associates this player in this lobby with a persistent connection. When a disconnect notification is recevied, this value is used to identify the associated player in a lobby to mark them as disconnected.
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[DataMember(Name = "allocationId", EmitDefaultValue = false)] |
|||
public string AllocationId{ get; } |
|||
|
|||
} |
|||
} |
|||
|
|
|||
fileFormatVersion: 2 |
|||
guid: 6cbd6e214eb8c4c7bbf8ec61356c1b22 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using UnityEngine.Scripting; |
|||
using System.Runtime.Serialization; |
|||
using Newtonsoft.Json; |
|||
using Newtonsoft.Json.Converters; |
|||
|
|||
|
|||
|
|||
namespace Unity.Services.Lobbies.Models |
|||
{ |
|||
/// <summary>
|
|||
/// A filter for an individual field that is applied to a query.
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[DataContract(Name = "QueryFilter")] |
|||
public class QueryFilter |
|||
{ |
|||
/// <summary>
|
|||
/// A filter for an individual field that is applied to a query.
|
|||
/// </summary>
|
|||
/// <param name="field">The name of the field to filter on. For custom data fields, the name of the index must be used instead of the field name.</param>
|
|||
/// <param name="value">The value to compare to the field being filtered. This value must be a string and it must be parsable as the same type as `field` (e.g. `integer` for MaxPlayers, `datetime` for Created, etc.). The value for `datetime` fields (Created, LastUpdated) must be in RFC3339 format. For example, in C# this can be achieved using the \"o\" format specifier: `return dateTime.ToString(\"o\", DateTimeFormatInfo.InvariantInfo);`. Refer to your language documentation for other methods to generate RFC3339-compatible datetime strings.</param>
|
|||
/// <param name="op">The operator used to compare the field to the filter value. Supports `CONTAINS` (only on the `Name` field), `EQ` (Equal), `NE` (Not Equal), `LT` (Less Than), `LE` (Less Than or Equal), `GT` (Greater Than), or `GE` (Greater Than or Equal).</param>
|
|||
[Preserve] |
|||
public QueryFilter(FieldOptions field, string value, OpOptions op) |
|||
{ |
|||
Field = field; |
|||
Value = value; |
|||
Op = op; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// The name of the field to filter on. For custom data fields, the name of the index must be used instead of the field name.
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[JsonConverter(typeof(StringEnumConverter))] |
|||
[DataMember(Name = "field", IsRequired = true, EmitDefaultValue = true)] |
|||
public FieldOptions Field{ get; } |
|||
|
|||
/// <summary>
|
|||
/// The value to compare to the field being filtered. This value must be a string and it must be parsable as the same type as `field` (e.g. `integer` for MaxPlayers, `datetime` for Created, etc.). The value for `datetime` fields (Created, LastUpdated) must be in RFC3339 format. For example, in C# this can be achieved using the \"o\" format specifier: `return dateTime.ToString(\"o\", DateTimeFormatInfo.InvariantInfo);`. Refer to your language documentation for other methods to generate RFC3339-compatible datetime strings.
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[DataMember(Name = "value", IsRequired = true, EmitDefaultValue = true)] |
|||
public string Value{ get; } |
|||
|
|||
/// <summary>
|
|||
/// The operator used to compare the field to the filter value. Supports `CONTAINS` (only on the `Name` field), `EQ` (Equal), `NE` (Not Equal), `LT` (Less Than), `LE` (Less Than or Equal), `GT` (Greater Than), or `GE` (Greater Than or Equal).
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[JsonConverter(typeof(StringEnumConverter))] |
|||
[DataMember(Name = "op", IsRequired = true, EmitDefaultValue = true)] |
|||
public OpOptions Op{ get; } |
|||
|
|||
|
|||
/// <summary>
|
|||
/// The name of the field to filter on. For custom data fields, the name of the index must be used instead of the field name.
|
|||
/// </summary>
|
|||
/// <value>The name of the field to filter on. For custom data fields, the name of the index must be used instead of the field name.</value>
|
|||
[JsonConverter(typeof(StringEnumConverter))] |
|||
public enum FieldOptions |
|||
{ |
|||
/// <summary>
|
|||
/// Enum MaxPlayers for value: MaxPlayers
|
|||
/// </summary>
|
|||
[EnumMember(Value = "MaxPlayers")] |
|||
MaxPlayers = 1, |
|||
|
|||
/// <summary>
|
|||
/// Enum AvailableSlots for value: AvailableSlots
|
|||
/// </summary>
|
|||
[EnumMember(Value = "AvailableSlots")] |
|||
AvailableSlots = 2, |
|||
|
|||
/// <summary>
|
|||
/// Enum Name for value: Name
|
|||
/// </summary>
|
|||
[EnumMember(Value = "Name")] |
|||
Name = 3, |
|||
|
|||
/// <summary>
|
|||
/// Enum Created for value: Created
|
|||
/// </summary>
|
|||
[EnumMember(Value = "Created")] |
|||
Created = 4, |
|||
|
|||
/// <summary>
|
|||
/// Enum LastUpdated for value: LastUpdated
|
|||
/// </summary>
|
|||
[EnumMember(Value = "LastUpdated")] |
|||
LastUpdated = 5, |
|||
|
|||
/// <summary>
|
|||
/// Enum S1 for value: S1
|
|||
/// </summary>
|
|||
[EnumMember(Value = "S1")] |
|||
S1 = 6, |
|||
|
|||
/// <summary>
|
|||
/// Enum S2 for value: S2
|
|||
/// </summary>
|
|||
[EnumMember(Value = "S2")] |
|||
S2 = 7, |
|||
|
|||
/// <summary>
|
|||
/// Enum S3 for value: S3
|
|||
/// </summary>
|
|||
[EnumMember(Value = "S3")] |
|||
S3 = 8, |
|||
|
|||
/// <summary>
|
|||
/// Enum S4 for value: S4
|
|||
/// </summary>
|
|||
[EnumMember(Value = "S4")] |
|||
S4 = 9, |
|||
|
|||
/// <summary>
|
|||
/// Enum S5 for value: S5
|
|||
/// </summary>
|
|||
[EnumMember(Value = "S5")] |
|||
S5 = 10, |
|||
|
|||
/// <summary>
|
|||
/// Enum N1 for value: N1
|
|||
/// </summary>
|
|||
[EnumMember(Value = "N1")] |
|||
N1 = 11, |
|||
|
|||
/// <summary>
|
|||
/// Enum N2 for value: N2
|
|||
/// </summary>
|
|||
[EnumMember(Value = "N2")] |
|||
N2 = 12, |
|||
|
|||
/// <summary>
|
|||
/// Enum N3 for value: N3
|
|||
/// </summary>
|
|||
[EnumMember(Value = "N3")] |
|||
N3 = 13, |
|||
|
|||
/// <summary>
|
|||
/// Enum N4 for value: N4
|
|||
/// </summary>
|
|||
[EnumMember(Value = "N4")] |
|||
N4 = 14, |
|||
|
|||
/// <summary>
|
|||
/// Enum N5 for value: N5
|
|||
/// </summary>
|
|||
[EnumMember(Value = "N5")] |
|||
N5 = 15 |
|||
|
|||
} |
|||
|
|||
|
|||
/// <summary>
|
|||
/// The operator used to compare the field to the filter value. Supports `CONTAINS` (only on the `Name` field), `EQ` (Equal), `NE` (Not Equal), `LT` (Less Than), `LE` (Less Than or Equal), `GT` (Greater Than), or `GE` (Greater Than or Equal).
|
|||
/// </summary>
|
|||
/// <value>The operator used to compare the field to the filter value. Supports `CONTAINS` (only on the `Name` field), `EQ` (Equal), `NE` (Not Equal), `LT` (Less Than), `LE` (Less Than or Equal), `GT` (Greater Than), or `GE` (Greater Than or Equal).</value>
|
|||
[JsonConverter(typeof(StringEnumConverter))] |
|||
public enum OpOptions |
|||
{ |
|||
/// <summary>
|
|||
/// Enum CONTAINS for value: CONTAINS
|
|||
/// </summary>
|
|||
[EnumMember(Value = "CONTAINS")] |
|||
CONTAINS = 1, |
|||
|
|||
/// <summary>
|
|||
/// Enum EQ for value: EQ
|
|||
/// </summary>
|
|||
[EnumMember(Value = "EQ")] |
|||
EQ = 2, |
|||
|
|||
/// <summary>
|
|||
/// Enum NE for value: NE
|
|||
/// </summary>
|
|||
[EnumMember(Value = "NE")] |
|||
NE = 3, |
|||
|
|||
/// <summary>
|
|||
/// Enum LT for value: LT
|
|||
/// </summary>
|
|||
[EnumMember(Value = "LT")] |
|||
LT = 4, |
|||
|
|||
/// <summary>
|
|||
/// Enum LE for value: LE
|
|||
/// </summary>
|
|||
[EnumMember(Value = "LE")] |
|||
LE = 5, |
|||
|
|||
/// <summary>
|
|||
/// Enum GT for value: GT
|
|||
/// </summary>
|
|||
[EnumMember(Value = "GT")] |
|||
GT = 6, |
|||
|
|||
/// <summary>
|
|||
/// Enum GE for value: GE
|
|||
/// </summary>
|
|||
[EnumMember(Value = "GE")] |
|||
GE = 7 |
|||
|
|||
} |
|||
|
|||
} |
|||
} |
|||
|
|
|||
fileFormatVersion: 2 |
|||
guid: 57811e6f3eb004081be3a7d2ae4ec9ac |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using UnityEngine.Scripting; |
|||
using System.Runtime.Serialization; |
|||
using Newtonsoft.Json; |
|||
using Newtonsoft.Json.Converters; |
|||
|
|||
|
|||
|
|||
namespace Unity.Services.Lobbies.Models |
|||
{ |
|||
/// <summary>
|
|||
/// An order for an individual field that is applied to a query.
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[DataContract(Name = "QueryOrder")] |
|||
public class QueryOrder |
|||
{ |
|||
/// <summary>
|
|||
/// An order for an individual field that is applied to a query.
|
|||
/// </summary>
|
|||
/// <param name="asc">Whether to sort in ascending or descending order.</param>
|
|||
/// <param name="field">The name of the field to order on.</param>
|
|||
[Preserve] |
|||
public QueryOrder(bool asc = default(bool), FieldOptions field = default) |
|||
{ |
|||
Asc = asc; |
|||
Field = field; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Whether to sort in ascending or descending order.
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[DataMember(Name = "asc", EmitDefaultValue = true)] |
|||
public bool Asc{ get; } |
|||
|
|||
/// <summary>
|
|||
/// The name of the field to order on.
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[JsonConverter(typeof(StringEnumConverter))] |
|||
[DataMember(Name = "field", EmitDefaultValue = false)] |
|||
public FieldOptions Field{ get; } |
|||
|
|||
|
|||
/// <summary>
|
|||
/// The name of the field to order on.
|
|||
/// </summary>
|
|||
/// <value>The name of the field to order on.</value>
|
|||
[JsonConverter(typeof(StringEnumConverter))] |
|||
public enum FieldOptions |
|||
{ |
|||
/// <summary>
|
|||
/// Enum Name for value: Name
|
|||
/// </summary>
|
|||
[EnumMember(Value = "Name")] |
|||
Name = 1, |
|||
|
|||
/// <summary>
|
|||
/// Enum MaxPlayers for value: MaxPlayers
|
|||
/// </summary>
|
|||
[EnumMember(Value = "MaxPlayers")] |
|||
MaxPlayers = 2, |
|||
|
|||
/// <summary>
|
|||
/// Enum AvailableSlots for value: AvailableSlots
|
|||
/// </summary>
|
|||
[EnumMember(Value = "AvailableSlots")] |
|||
AvailableSlots = 3, |
|||
|
|||
/// <summary>
|
|||
/// Enum Created for value: Created
|
|||
/// </summary>
|
|||
[EnumMember(Value = "Created")] |
|||
Created = 4, |
|||
|
|||
/// <summary>
|
|||
/// Enum LastUpdated for value: LastUpdated
|
|||
/// </summary>
|
|||
[EnumMember(Value = "LastUpdated")] |
|||
LastUpdated = 5, |
|||
|
|||
/// <summary>
|
|||
/// Enum ID for value: ID
|
|||
/// </summary>
|
|||
[EnumMember(Value = "ID")] |
|||
ID = 6, |
|||
|
|||
/// <summary>
|
|||
/// Enum S1 for value: S1
|
|||
/// </summary>
|
|||
[EnumMember(Value = "S1")] |
|||
S1 = 7, |
|||
|
|||
/// <summary>
|
|||
/// Enum S2 for value: S2
|
|||
/// </summary>
|
|||
[EnumMember(Value = "S2")] |
|||
S2 = 8, |
|||
|
|||
/// <summary>
|
|||
/// Enum S3 for value: S3
|
|||
/// </summary>
|
|||
[EnumMember(Value = "S3")] |
|||
S3 = 9, |
|||
|
|||
/// <summary>
|
|||
/// Enum S4 for value: S4
|
|||
/// </summary>
|
|||
[EnumMember(Value = "S4")] |
|||
S4 = 10, |
|||
|
|||
/// <summary>
|
|||
/// Enum S5 for value: S5
|
|||
/// </summary>
|
|||
[EnumMember(Value = "S5")] |
|||
S5 = 11, |
|||
|
|||
/// <summary>
|
|||
/// Enum N1 for value: N1
|
|||
/// </summary>
|
|||
[EnumMember(Value = "N1")] |
|||
N1 = 12, |
|||
|
|||
/// <summary>
|
|||
/// Enum N2 for value: N2
|
|||
/// </summary>
|
|||
[EnumMember(Value = "N2")] |
|||
N2 = 13, |
|||
|
|||
/// <summary>
|
|||
/// Enum N3 for value: N3
|
|||
/// </summary>
|
|||
[EnumMember(Value = "N3")] |
|||
N3 = 14, |
|||
|
|||
/// <summary>
|
|||
/// Enum N4 for value: N4
|
|||
/// </summary>
|
|||
[EnumMember(Value = "N4")] |
|||
N4 = 15, |
|||
|
|||
/// <summary>
|
|||
/// Enum N5 for value: N5
|
|||
/// </summary>
|
|||
[EnumMember(Value = "N5")] |
|||
N5 = 16 |
|||
|
|||
} |
|||
|
|||
} |
|||
} |
|||
|
|
|||
fileFormatVersion: 2 |
|||
guid: 13dd81cf4377f4067abf8c45b64aa8a9 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using UnityEngine.Scripting; |
|||
using System.Runtime.Serialization; |
|||
using Newtonsoft.Json; |
|||
using Newtonsoft.Json.Converters; |
|||
|
|||
|
|||
|
|||
namespace Unity.Services.Lobbies.Models |
|||
{ |
|||
/// <summary>
|
|||
/// The body of a Query request which defines how to sort and filter results, how many results to return, etc.
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[DataContract(Name = "QueryRequest")] |
|||
public class QueryRequest |
|||
{ |
|||
/// <summary>
|
|||
/// The body of a Query request which defines how to sort and filter results, how many results to return, etc.
|
|||
/// </summary>
|
|||
/// <param name="count">The number of results to return.</param>
|
|||
/// <param name="skip">The number of results to skip before selecting results to return.</param>
|
|||
/// <param name="sampleResults">Whether a random sample of results that match the search filter should be returned.</param>
|
|||
/// <param name="filter">A list of filters which can be used to narrow down which lobbies to return.</param>
|
|||
/// <param name="order">A list of orders which define how the results should be ordered in the response.</param>
|
|||
/// <param name="continuationToken">A continuation token that can be passed to subsequent query requests to fetch the next page of results.</param>
|
|||
[Preserve] |
|||
public QueryRequest(int? count = null, int? skip = null, bool sampleResults = false, List<QueryFilter> filter = default(List<QueryFilter>), List<QueryOrder> order = default(List<QueryOrder>), string continuationToken = null) |
|||
{ |
|||
Count = count; |
|||
Skip = skip; |
|||
SampleResults = sampleResults; |
|||
Filter = filter; |
|||
Order = order; |
|||
ContinuationToken = continuationToken; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// The number of results to return.
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[DataMember(Name = "count", EmitDefaultValue = false)] |
|||
public int? Count{ get; } |
|||
|
|||
/// <summary>
|
|||
/// The number of results to skip before selecting results to return.
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[DataMember(Name = "skip", EmitDefaultValue = false)] |
|||
public int? Skip{ get; } |
|||
|
|||
/// <summary>
|
|||
/// Whether a random sample of results that match the search filter should be returned.
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[DataMember(Name = "sampleResults", EmitDefaultValue = true)] |
|||
public bool SampleResults{ get; } |
|||
|
|||
/// <summary>
|
|||
/// A list of filters which can be used to narrow down which lobbies to return.
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[DataMember(Name = "filter", EmitDefaultValue = false)] |
|||
public List<QueryFilter> Filter{ get; } |
|||
|
|||
/// <summary>
|
|||
/// A list of orders which define how the results should be ordered in the response.
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[DataMember(Name = "order", EmitDefaultValue = false)] |
|||
public List<QueryOrder> Order{ get; } |
|||
|
|||
/// <summary>
|
|||
/// A continuation token that can be passed to subsequent query requests to fetch the next page of results.
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[DataMember(Name = "continuationToken", EmitDefaultValue = false)] |
|||
public string ContinuationToken{ get; } |
|||
|
|||
} |
|||
} |
|||
|
|
|||
fileFormatVersion: 2 |
|||
guid: 8e9681add0b7c4690abb80579eed3a78 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using UnityEngine.Scripting; |
|||
using System.Runtime.Serialization; |
|||
using Newtonsoft.Json; |
|||
using Newtonsoft.Json.Converters; |
|||
|
|||
|
|||
|
|||
namespace Unity.Services.Lobbies.Models |
|||
{ |
|||
/// <summary>
|
|||
/// A list of lobbies that matched the specified lobbies query. Only the public top level, data, and player data properties are returned.
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[DataContract(Name = "QueryResponse")] |
|||
public class QueryResponse |
|||
{ |
|||
/// <summary>
|
|||
/// A list of lobbies that matched the specified lobbies query. Only the public top level, data, and player data properties are returned.
|
|||
/// </summary>
|
|||
/// <param name="results">results param</param>
|
|||
/// <param name="continuationToken">continuationToken param</param>
|
|||
[Preserve] |
|||
public QueryResponse(List<Lobby> results = default(List<Lobby>), string continuationToken = null) |
|||
{ |
|||
Results = results; |
|||
ContinuationToken = continuationToken; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// results param
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[DataMember(Name = "results", EmitDefaultValue = false)] |
|||
public List<Lobby> Results{ get; } |
|||
|
|||
/// <summary>
|
|||
/// continuationToken param
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[DataMember(Name = "continuationToken", EmitDefaultValue = false)] |
|||
public string ContinuationToken{ get; } |
|||
|
|||
} |
|||
} |
|||
|
|
|||
fileFormatVersion: 2 |
|||
guid: dc2b6c2759084442883482161a87370a |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using UnityEngine.Scripting; |
|||
using System.Runtime.Serialization; |
|||
using Newtonsoft.Json; |
|||
using Newtonsoft.Json.Converters; |
|||
|
|||
|
|||
|
|||
namespace Unity.Services.Lobbies.Models |
|||
{ |
|||
/// <summary>
|
|||
/// The body of a QuickJoin request.
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[DataContract(Name = "QuickJoinRequest")] |
|||
public class QuickJoinRequest |
|||
{ |
|||
/// <summary>
|
|||
/// The body of a QuickJoin request.
|
|||
/// </summary>
|
|||
/// <param name="filter">A list of filters which can be used to narrow down which lobbies to attempt to join..</param>
|
|||
/// <param name="player">player param</param>
|
|||
[Preserve] |
|||
public QuickJoinRequest(List<QueryFilter> filter = default(List<QueryFilter>), Player player = default(Player)) |
|||
{ |
|||
Filter = filter; |
|||
Player = player; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// A list of filters which can be used to narrow down which lobbies to attempt to join..
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[DataMember(Name = "filter", EmitDefaultValue = false)] |
|||
public List<QueryFilter> Filter{ get; } |
|||
|
|||
/// <summary>
|
|||
/// player param
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[DataMember(Name = "player", EmitDefaultValue = false)] |
|||
public Player Player{ get; } |
|||
|
|||
} |
|||
} |
|||
|
|
|||
fileFormatVersion: 2 |
|||
guid: 6a5c71bcafd784dcc88bbc76d2db823a |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using UnityEngine.Scripting; |
|||
using System.Runtime.Serialization; |
|||
using Newtonsoft.Json; |
|||
using Newtonsoft.Json.Converters; |
|||
|
|||
|
|||
|
|||
namespace Unity.Services.Lobbies.Models |
|||
{ |
|||
/// <summary>
|
|||
/// The body of an Update Lobby request.
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[DataContract(Name = "UpdateRequest")] |
|||
public class UpdateRequest |
|||
{ |
|||
/// <summary>
|
|||
/// The body of an Update Lobby request.
|
|||
/// </summary>
|
|||
/// <param name="name">The name of the lobby that should be displayed to users. All whitespace will be trimmed from name.</param>
|
|||
/// <param name="maxPlayers">The maximum number of players allowed in the lobby. Must be greater than or equal to the current number of players in the lobby.</param>
|
|||
/// <param name="isPrivate">Indicates whether or not the lobby is publicly visible and will show up in query results. If the lobby is not publicly visible, the creator can share the `lobbyCode` with other users who can use it to join this lobby.</param>
|
|||
/// <param name="data">Custom game-specific properties to add, update, or remove from the lobby (e.g. `mapName` or `gameType`). To remove an existing property, include it in `data` but set the property object to `null`. To update the value to `null`, set the `value` property of the object to `null`.</param>
|
|||
/// <param name="hostId">The id of the player to make the host of the lobby. As soon as this is updated the current host will no longer have permission to modify the lobby.</param>
|
|||
[Preserve] |
|||
public UpdateRequest(string name = null, int? maxPlayers = null, bool? isPrivate = null, Dictionary<string, DataObject> data = null, string hostId = null) |
|||
{ |
|||
Name = name; |
|||
MaxPlayers = maxPlayers; |
|||
IsPrivate = isPrivate; |
|||
Data = data; |
|||
HostId = hostId; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// The name of the lobby that should be displayed to users. All whitespace will be trimmed from name.
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[DataMember(Name = "name", EmitDefaultValue = false)] |
|||
public string Name{ get; } |
|||
|
|||
/// <summary>
|
|||
/// The maximum number of players allowed in the lobby. Must be greater than or equal to the current number of players in the lobby.
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[DataMember(Name = "maxPlayers", EmitDefaultValue = false)] |
|||
public int? MaxPlayers{ get; } |
|||
|
|||
/// <summary>
|
|||
/// Indicates whether or not the lobby is publicly visible and will show up in query results. If the lobby is not publicly visible, the creator can share the `lobbyCode` with other users who can use it to join this lobby.
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[DataMember(Name = "isPrivate", EmitDefaultValue = true)] |
|||
public bool? IsPrivate{ get; } |
|||
|
|||
/// <summary>
|
|||
/// Custom game-specific properties to add, update, or remove from the lobby (e.g. `mapName` or `gameType`). To remove an existing property, include it in `data` but set the property object to `null`. To update the value to `null`, set the `value` property of the object to `null`.
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[DataMember(Name = "data", EmitDefaultValue = false)] |
|||
public Dictionary<string, DataObject> Data{ get; } |
|||
|
|||
/// <summary>
|
|||
/// The id of the player to make the host of the lobby. As soon as this is updated the current host will no longer have permission to modify the lobby.
|
|||
/// </summary>
|
|||
[Preserve] |
|||
[DataMember(Name = "hostId", EmitDefaultValue = false)] |
|||
public string HostId{ get; } |
|||
|
|||
} |
|||
} |
|||
|
|
|||
fileFormatVersion: 2 |
|||
guid: c50951a05f90d4ecba6fd8c11bf9769b |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: bc8ad623ce34c4ce887fd09acbfdf978 |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
部分文件因为文件数量过多而无法显示
撰写
预览
正在加载...
取消
保存
Reference in new issue