From 88fe9f9820a9c5eeaea918496d5cabd0ae381ed9 Mon Sep 17 00:00:00 2001
From: MrGadget <9826063+MrGadget1024@users.noreply.github.com>
Date: Mon, 13 Dec 2021 07:39:30 -0500
Subject: [PATCH] breaking: NetworkAuthenticator OnClientAuthenticated Changed
(#3027)
- No longer passes `NetworkConnection` on Client
- Use `NetworkClient.connection` within your event hanlder
This is only breaking for users that assigned their own events to OnClientAuthenticated in the inspector. Everything else related to an Authenticator works the same with no changes needed because nearly all Authenticator mechanisms are private.
Deprecating would be worse than not in this case, since custom user-made handers would be the far uncommon case as far as I know.
---
Assets/Mirror/Authenticators/TimeoutAuthenticator.cs | 6 +++---
Assets/Mirror/CompilerSymbols/PreprocessorDefine.cs | 3 ++-
Assets/Mirror/Runtime/NetworkAuthenticator.cs | 4 ++--
Assets/Mirror/Runtime/NetworkManager.cs | 4 ++--
ProjectSettings/ProjectSettings.asset | 2 +-
5 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/Assets/Mirror/Authenticators/TimeoutAuthenticator.cs b/Assets/Mirror/Authenticators/TimeoutAuthenticator.cs
index 28f989bf9..16e667e90 100644
--- a/Assets/Mirror/Authenticators/TimeoutAuthenticator.cs
+++ b/Assets/Mirror/Authenticators/TimeoutAuthenticator.cs
@@ -18,7 +18,7 @@ public class TimeoutAuthenticator : NetworkAuthenticator
public void Awake()
{
authenticator.OnServerAuthenticated.AddListener(connection => OnServerAuthenticated.Invoke(connection));
- authenticator.OnClientAuthenticated.AddListener(connection => OnClientAuthenticated.Invoke(connection));
+ authenticator.OnClientAuthenticated.AddListener(OnClientAuthenticated.Invoke);
}
public override void OnStartServer()
@@ -57,12 +57,12 @@ public override void OnClientAuthenticate()
IEnumerator BeginAuthentication(NetworkConnection conn)
{
- // Debug.Log($"Authentication countdown started {conn} {timeout}");
+ //Debug.Log($"Authentication countdown started {conn} {timeout}");
yield return new WaitForSecondsRealtime(timeout);
if (!conn.isAuthenticated)
{
- // Debug.Log($"Authentication Timeout {conn}");
+ Debug.LogError($"Authentication Timeout - Disconnecting {conn}");
conn.Disconnect();
}
}
diff --git a/Assets/Mirror/CompilerSymbols/PreprocessorDefine.cs b/Assets/Mirror/CompilerSymbols/PreprocessorDefine.cs
index 6944d1964..9a38c1172 100644
--- a/Assets/Mirror/CompilerSymbols/PreprocessorDefine.cs
+++ b/Assets/Mirror/CompilerSymbols/PreprocessorDefine.cs
@@ -38,7 +38,8 @@ public static void AddDefineSymbols()
"MIRROR_44_0_OR_NEWER",
"MIRROR_46_0_OR_NEWER",
"MIRROR_47_0_OR_NEWER",
- "MIRROR_53_0_OR_NEWER"
+ "MIRROR_53_0_OR_NEWER",
+ "MIRROR_55_0_OR_NEWER"
};
// only touch PlayerSettings if we actually modified it.
diff --git a/Assets/Mirror/Runtime/NetworkAuthenticator.cs b/Assets/Mirror/Runtime/NetworkAuthenticator.cs
index 6a834275a..20c1352d1 100644
--- a/Assets/Mirror/Runtime/NetworkAuthenticator.cs
+++ b/Assets/Mirror/Runtime/NetworkAuthenticator.cs
@@ -17,7 +17,7 @@ public abstract class NetworkAuthenticator : MonoBehaviour
/// Notify subscribers on the client when the client is authenticated
[Tooltip("Mirror has an internal subscriber to this event. You can add your own here.")]
- public UnityEventNetworkConnection OnClientAuthenticated = new UnityEventNetworkConnection();
+ public UnityEvent OnClientAuthenticated = new UnityEvent();
/// Called when server starts, used to register message handlers if needed.
public virtual void OnStartServer() {}
@@ -49,7 +49,7 @@ public virtual void OnStopClient() {}
protected void ClientAccept()
{
- OnClientAuthenticated.Invoke(NetworkClient.connection);
+ OnClientAuthenticated.Invoke();
}
protected void ClientReject()
diff --git a/Assets/Mirror/Runtime/NetworkManager.cs b/Assets/Mirror/Runtime/NetworkManager.cs
index c95c2fd47..246e16574 100644
--- a/Assets/Mirror/Runtime/NetworkManager.cs
+++ b/Assets/Mirror/Runtime/NetworkManager.cs
@@ -1159,12 +1159,12 @@ void OnClientConnectInternal()
else
{
// authenticate immediately
- OnClientAuthenticated(NetworkClient.connection);
+ OnClientAuthenticated();
}
}
// called after successful authentication
- void OnClientAuthenticated(NetworkConnection conn)
+ void OnClientAuthenticated()
{
//Debug.Log("NetworkManager.OnClientAuthenticated");
diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset
index 465aec59e..7aecca87d 100644
--- a/ProjectSettings/ProjectSettings.asset
+++ b/ProjectSettings/ProjectSettings.asset
@@ -576,7 +576,7 @@ PlayerSettings:
webGLThreadsSupport: 0
webGLWasmStreaming: 0
scriptingDefineSymbols:
- 1: MIRROR;MIRROR_17_0_OR_NEWER;MIRROR_18_0_OR_NEWER;MIRROR_24_0_OR_NEWER;MIRROR_26_0_OR_NEWER;MIRROR_27_0_OR_NEWER;MIRROR_28_0_OR_NEWER;MIRROR_29_0_OR_NEWER;MIRROR_30_0_OR_NEWER;MIRROR_30_5_2_OR_NEWER;MIRROR_32_1_2_OR_NEWER;MIRROR_32_1_4_OR_NEWER;MIRROR_35_0_OR_NEWER;MIRROR_35_1_OR_NEWER;MIRROR_37_0_OR_NEWER;MIRROR_38_0_OR_NEWER;MIRROR_39_0_OR_NEWER;MIRROR_40_0_OR_NEWER;MIRROR_41_0_OR_NEWER;MIRROR_42_0_OR_NEWER;MIRROR_43_0_OR_NEWER;MIRROR_44_0_OR_NEWER;MIRROR_46_0_OR_NEWER;MIRROR_47_0_OR_NEWER;MIRROR_53_0_OR_NEWER
+ 1: MIRROR;MIRROR_17_0_OR_NEWER;MIRROR_18_0_OR_NEWER;MIRROR_24_0_OR_NEWER;MIRROR_26_0_OR_NEWER;MIRROR_27_0_OR_NEWER;MIRROR_28_0_OR_NEWER;MIRROR_29_0_OR_NEWER;MIRROR_30_0_OR_NEWER;MIRROR_30_5_2_OR_NEWER;MIRROR_32_1_2_OR_NEWER;MIRROR_32_1_4_OR_NEWER;MIRROR_35_0_OR_NEWER;MIRROR_35_1_OR_NEWER;MIRROR_37_0_OR_NEWER;MIRROR_38_0_OR_NEWER;MIRROR_39_0_OR_NEWER;MIRROR_40_0_OR_NEWER;MIRROR_41_0_OR_NEWER;MIRROR_42_0_OR_NEWER;MIRROR_43_0_OR_NEWER;MIRROR_44_0_OR_NEWER;MIRROR_46_0_OR_NEWER;MIRROR_47_0_OR_NEWER;MIRROR_53_0_OR_NEWER;MIRROR_55_0_OR_NEWER
platformArchitecture: {}
scriptingBackend: {}
il2cppCompilerConfiguration: {}