From a74f8f9ea219e4e4bdc12cf62e1fb1c76a12f6bd Mon Sep 17 00:00:00 2001 From: MrGadget1024 <9826063+MrGadget1024@users.noreply.github.com> Date: Mon, 6 Mar 2023 09:13:48 -0500 Subject: [PATCH] Revert "breaking!(NetworkManager): Removed obsolete OnServerError / OnClientError" This reverts commit d45bd661ef16943c448bee0079c0e41bc7668747. --- Assets/Mirror/Core/NetworkManager.cs | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/Assets/Mirror/Core/NetworkManager.cs b/Assets/Mirror/Core/NetworkManager.cs index 80d867e11..f24d8ce9b 100644 --- a/Assets/Mirror/Core/NetworkManager.cs +++ b/Assets/Mirror/Core/NetworkManager.cs @@ -1306,8 +1306,16 @@ public virtual void OnServerAddPlayer(NetworkConnectionToClient conn) NetworkServer.AddPlayerForConnection(conn, player); } + // Deprecated 2022-05-12 + [Obsolete("OnServerError(conn, Exception) was changed to OnServerError(conn, TransportError, string)")] + public virtual void OnServerError(NetworkConnectionToClient conn, Exception exception) {} /// Called on server when transport raises an exception. NetworkConnection may be null. - public virtual void OnServerError(NetworkConnectionToClient conn, TransportError error, string reason) {} + public virtual void OnServerError(NetworkConnectionToClient conn, TransportError error, string reason) + { +#pragma warning disable CS0618 + OnServerError(conn, new Exception(reason)); +#pragma warning restore CS0618 + } /// Called from ServerChangeScene immediately before SceneManager.LoadSceneAsync is executed public virtual void OnServerChangeScene(string newSceneName) {} @@ -1336,8 +1344,16 @@ public virtual void OnClientConnect() /// Called on clients when disconnected from a server. public virtual void OnClientDisconnect() {} + // Deprecated 2022-05-12 + [Obsolete("OnClientError(Exception) was changed to OnClientError(TransportError, string)")] + public virtual void OnClientError(Exception exception) {} /// Called on client when transport raises an exception. - public virtual void OnClientError(TransportError error, string reason) {} + public virtual void OnClientError(TransportError error, string reason) + { +#pragma warning disable CS0618 + OnClientError(new Exception(reason)); +#pragma warning restore CS0618 + } /// Called on clients when a servers tells the client it is no longer ready, e.g. when switching scenes. public virtual void OnClientNotReady() {}