Skip to content
This repository has been archived by the owner on Sep 5, 2022. It is now read-only.

Commit

Permalink
Asset Store Version Support
Browse files Browse the repository at this point in the history
  • Loading branch information
Derek-R-S committed May 18, 2021
1 parent 5f0b40d commit c3558be
Show file tree
Hide file tree
Showing 560 changed files with 3,337 additions and 1,867 deletions.
6 changes: 3 additions & 3 deletions UnityProject/Assets/Mirror/Authenticators.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 9 additions & 17 deletions UnityProject/Assets/Mirror/Authenticators/BasicAuthenticator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ public class BasicAuthenticator : NetworkAuthenticator
public string username;
public string password;

// this is set if authentication fails to prevent garbage AuthRequestMessage spam
bool ServerAuthFailed;

#region Messages

public struct AuthRequestMessage : NetworkMessage
Expand Down Expand Up @@ -104,13 +101,7 @@ public void OnAuthRequestMessage(NetworkConnection conn, AuthRequestMessage msg)
conn.isAuthenticated = false;

// disconnect the client after 1 second so that response message gets delivered
if (!ServerAuthFailed)
{
// set this false so this coroutine can only be started once
ServerAuthFailed = true;

StartCoroutine(DelayedDisconnect(conn, 1));
}
StartCoroutine(DelayedDisconnect(conn, 1));
}
}

Expand Down Expand Up @@ -150,23 +141,21 @@ public override void OnStopClient()
/// Called on client from OnClientAuthenticateInternal when a client needs to authenticate
/// </summary>
/// <param name="conn">Connection of the client.</param>
public override void OnClientAuthenticate()
public override void OnClientAuthenticate(NetworkConnection conn)
{
AuthRequestMessage authRequestMessage = new AuthRequestMessage
{
authUsername = username,
authPassword = password
};

NetworkClient.connection.Send(authRequestMessage);
conn.Send(authRequestMessage);
}

[Obsolete("Call OnAuthResponseMessage without the NetworkConnection parameter. It always points to NetworkClient.connection anyway.")]
public void OnAuthResponseMessage(NetworkConnection conn, AuthResponseMessage msg) => OnAuthResponseMessage(msg);

/// <summary>
/// Called on client when the server's AuthResponseMessage arrives
/// </summary>
/// <param name="conn">Connection to client.</param>
/// <param name="msg">The message payload</param>
public void OnAuthResponseMessage(AuthResponseMessage msg)
{
Expand All @@ -175,17 +164,20 @@ public void OnAuthResponseMessage(AuthResponseMessage msg)
// Debug.LogFormat(LogType.Log, "Authentication Response: {0}", msg.message);

// Authentication has been accepted
ClientAccept();
ClientAccept(NetworkClient.connection);
}
else
{
Debug.LogError($"Authentication Response: {msg.message}");

// Authentication has been rejected
ClientReject();
ClientReject(NetworkClient.connection);
}
}

[Obsolete("Call OnAuthResponseMessage without the NetworkConnection parameter. It always points to NetworkClient.connection anyway.")]
public void OnAuthResponseMessage(NetworkConnection conn, AuthResponseMessage msg) => OnAuthResponseMessage(msg);

#endregion
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,23 @@ public override void OnServerAuthenticate(NetworkConnection conn)
StartCoroutine(BeginAuthentication(conn));
}

public override void OnClientAuthenticate()
public override void OnClientAuthenticate(NetworkConnection conn)
{
authenticator.OnClientAuthenticate();
authenticator.OnClientAuthenticate(conn);
if (timeout > 0)
StartCoroutine(BeginAuthentication(NetworkClient.connection));
StartCoroutine(BeginAuthentication(conn));
}

IEnumerator BeginAuthentication(NetworkConnection conn)
{
// Debug.Log($"Authentication countdown started {conn} {timeout}");

yield return new WaitForSecondsRealtime(timeout);

if (!conn.isAuthenticated)
{
// Debug.Log($"Authentication Timeout {conn}");

conn.Disconnect();
}
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions UnityProject/Assets/Mirror/Cloud.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

62 changes: 61 additions & 1 deletion UnityProject/Assets/Mirror/Cloud/ApiConnector.cs
Original file line number Diff line number Diff line change
@@ -1 +1,61 @@
// removed 2021-05-13
using Mirror.Cloud.ListServerService;
using UnityEngine;

namespace Mirror.Cloud
{
/// <summary>
/// Used to requests and responses from the mirror api
/// </summary>
public interface IApiConnector
{
ListServer ListServer { get; }
}

/// <summary>
/// Used to requests and responses from the mirror api
/// </summary>
[DisallowMultipleComponent]
[AddComponentMenu("Network/CloudServices/ApiConnector")]
[HelpURL("https://mirror-networking.com/docs/api/Mirror.Cloud.ApiConnector.html")]
public class ApiConnector : MonoBehaviour, IApiConnector, ICoroutineRunner
{
#region Inspector
[Header("Settings")]

[Tooltip("Base URL of api, including https")]
[SerializeField] string ApiAddress = "";

[Tooltip("Api key required to access api")]
[SerializeField] string ApiKey = "";

[Header("Events")]

[Tooltip("Triggered when server list updates")]
[SerializeField] ServerListEvent _onServerListUpdated = new ServerListEvent();
#endregion

IRequestCreator requestCreator;

public ListServer ListServer { get; private set; }

void Awake()
{
requestCreator = new RequestCreator(ApiAddress, ApiKey, this);

InitListServer();
}

void InitListServer()
{
IListServerServerApi serverApi = new ListServerServerApi(this, requestCreator);
IListServerClientApi clientApi = new ListServerClientApi(this, requestCreator, _onServerListUpdated);
ListServer = new ListServer(serverApi, clientApi);
}

public void OnDestroy()
{
ListServer?.ServerApi.Shutdown();
ListServer?.ClientApi.Shutdown();
}
}
}
6 changes: 3 additions & 3 deletions UnityProject/Assets/Mirror/Cloud/ApiConnector.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 25 additions & 1 deletion UnityProject/Assets/Mirror/Cloud/Core/BaseApi.cs
Original file line number Diff line number Diff line change
@@ -1 +1,25 @@
// removed 2021-05-13
using System;

namespace Mirror.Cloud
{
public interface IBaseApi
{
/// <summary>
/// Cleans up any data created by the instance
/// <para>For Example: removing server from list</para>
/// </summary>
void Shutdown();
}

public abstract class BaseApi
{
protected readonly ICoroutineRunner runner;
protected readonly IRequestCreator requestCreator;

protected BaseApi(ICoroutineRunner runner, IRequestCreator requestCreator)
{
this.runner = runner ?? throw new ArgumentNullException(nameof(runner));
this.requestCreator = requestCreator ?? throw new ArgumentNullException(nameof(requestCreator));
}
}
}
6 changes: 3 additions & 3 deletions UnityProject/Assets/Mirror/Cloud/Core/BaseApi.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 12 additions & 1 deletion UnityProject/Assets/Mirror/Cloud/Core/Events.cs
Original file line number Diff line number Diff line change
@@ -1 +1,12 @@
// removed 2021-05-13
using System;
using Mirror.Cloud.ListServerService;
using UnityEngine.Events;

namespace Mirror.Cloud
{
[Serializable]
public class ServerListEvent : UnityEvent<ServerCollectionJson> {}

[Serializable]
public class MatchFoundEvent : UnityEvent<ServerJson> {}
}
6 changes: 3 additions & 3 deletions UnityProject/Assets/Mirror/Cloud/Core/Events.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 12 additions & 1 deletion UnityProject/Assets/Mirror/Cloud/Core/Extensions.cs
Original file line number Diff line number Diff line change
@@ -1 +1,12 @@
// removed 2021-05-13
using UnityEngine.Networking;

namespace Mirror.Cloud
{
public static class Extensions
{
public static bool IsOk(this UnityWebRequest webRequest)
{
return 200 <= webRequest.responseCode && webRequest.responseCode <= 299;
}
}
}
6 changes: 3 additions & 3 deletions UnityProject/Assets/Mirror/Cloud/Core/Extensions.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 12 additions & 1 deletion UnityProject/Assets/Mirror/Cloud/Core/ICoroutineRunner.cs
Original file line number Diff line number Diff line change
@@ -1 +1,12 @@
// removed 2021-05-13
using System.Collections;
using UnityEngine;

namespace Mirror.Cloud
{
public interface ICoroutineRunner : IUnityEqualCheck
{
Coroutine StartCoroutine(IEnumerator routine);
void StopCoroutine(IEnumerator routine);
void StopCoroutine(Coroutine routine);
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 42 additions & 1 deletion UnityProject/Assets/Mirror/Cloud/Core/IRequestCreator.cs
Original file line number Diff line number Diff line change
@@ -1 +1,42 @@
// removed 2021-05-13
using System.Collections;
using UnityEngine.Networking;

namespace Mirror.Cloud
{
public delegate void RequestSuccess(string responseBody);

public delegate void RequestFail(string responseBody);

/// <summary>
/// Objects that can be sent to the Api must have this interface
/// </summary>
public interface ICanBeJson {}

/// <summary>
/// Methods to create and send UnityWebRequest
/// </summary>
public interface IRequestCreator
{
UnityWebRequest Delete(string page);
UnityWebRequest Get(string page);
UnityWebRequest Patch<T>(string page, T json) where T : struct, ICanBeJson;
UnityWebRequest Post<T>(string page, T json) where T : struct, ICanBeJson;

/// <summary>
/// Sends Request to api and invokes callback when finished
/// <para>Starts Coroutine of SendRequestEnumerator</para>
/// </summary>
/// <param name="request"></param>
/// <param name="onSuccess"></param>
/// <param name="onFail"></param>
void SendRequest(UnityWebRequest request, RequestSuccess onSuccess = null, RequestFail onFail = null);
/// <summary>
/// Sends Request to api and invokes callback when finished
/// </summary>
/// <param name="request"></param>
/// <param name="onSuccess"></param>
/// <param name="onFail"></param>
/// <returns></returns>
IEnumerator SendRequestEnumerator(UnityWebRequest request, RequestSuccess onSuccess = null, RequestFail onFail = null);
}
}
6 changes: 3 additions & 3 deletions UnityProject/Assets/Mirror/Cloud/Core/IRequestCreator.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit c3558be

Please sign in to comment.