From 8901b320408dd09b2af1c865a3c9bc7406826aed Mon Sep 17 00:00:00 2001 From: James Frowen Date: Mon, 6 May 2024 21:33:47 +0100 Subject: [PATCH] refactor: using new SendToAll method --- Assets/Mirage/Runtime/NetworkSceneManager.cs | 2 +- Assets/Mirage/Runtime/NetworkServer.cs | 3 ++- .../MultipleAdditiveScenes/Scripts/MultiSceneNetManager.cs | 2 +- Assets/Mirage/Samples~/Snippets/SendNetworkMessage.cs | 2 +- Assets/Tests/Runtime/ClientServerSendTo.cs | 2 +- Assets/Tests/Runtime/HostSendTo.cs | 2 +- Assets/Tests/Runtime/SendToAllocations.cs | 2 +- 7 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Assets/Mirage/Runtime/NetworkSceneManager.cs b/Assets/Mirage/Runtime/NetworkSceneManager.cs index 85ece4dc4a..144943076c 100644 --- a/Assets/Mirage/Runtime/NetworkSceneManager.cs +++ b/Assets/Mirage/Runtime/NetworkSceneManager.cs @@ -609,7 +609,7 @@ internal void OnServerFinishedSceneLoad(Scene scene, SceneOperation operation) // todo this might cause issues if only some players are loading scene // send to all, excluding host - Server.SendToAll(new SceneReadyMessage(), excludeLocalPlayer: true); + Server.SendToAll(new SceneReadyMessage(), authenticatedOnly: false, excludeLocalPlayer: true); // clean up and invoke server functions before user events Server.World.RemoveDestroyedObjects(); diff --git a/Assets/Mirage/Runtime/NetworkServer.cs b/Assets/Mirage/Runtime/NetworkServer.cs index de8f6b8e94..39cb4d6e61 100644 --- a/Assets/Mirage/Runtime/NetworkServer.cs +++ b/Assets/Mirage/Runtime/NetworkServer.cs @@ -476,8 +476,9 @@ internal void AddLocalConnection(NetworkClient client, IConnection connection) Authenticator.PreAddHostPlayer(player); } - [Obsolete("Use SendToAll(msg, authenticatedOnly, excludeLocalPlayer, channelId) instead", true)] + [Obsolete("Use SendToAll(msg, authenticatedOnly, excludeLocalPlayer, channelId) instead")] public void SendToAll(T msg, bool excludeLocalPlayer, Channel channelId = Channel.Reliable) => SendToAll(msg, authenticatedOnly: false, excludeLocalPlayer, channelId); + public void SendToAll(T msg, bool authenticatedOnly, bool excludeLocalPlayer, Channel channelId = Channel.Reliable) { if (authenticatedOnly) diff --git a/Assets/Mirage/Samples~/MultipleAdditiveScenes/Scripts/MultiSceneNetManager.cs b/Assets/Mirage/Samples~/MultipleAdditiveScenes/Scripts/MultiSceneNetManager.cs index ed65b7055e..0a6cb269aa 100644 --- a/Assets/Mirage/Samples~/MultipleAdditiveScenes/Scripts/MultiSceneNetManager.cs +++ b/Assets/Mirage/Samples~/MultipleAdditiveScenes/Scripts/MultiSceneNetManager.cs @@ -81,7 +81,7 @@ public void OnStopServer() { // note: if in host mode you may not want to send SceneMessage to host player. In that case use the excludeLocalPlayer flag var msg = new SceneMessage { MainActivateScene = gameScene, SceneOperation = SceneOperation.UnloadAdditive }; - Server.SendToAll(msg, excludeLocalPlayer: true); + Server.SendToAll(msg, authenticatedOnly: true, excludeLocalPlayer: true); StartCoroutine(UnloadSubScenes()); } diff --git a/Assets/Mirage/Samples~/Snippets/SendNetworkMessage.cs b/Assets/Mirage/Samples~/Snippets/SendNetworkMessage.cs index d316eff482..5419f18d29 100644 --- a/Assets/Mirage/Samples~/Snippets/SendNetworkMessage.cs +++ b/Assets/Mirage/Samples~/Snippets/SendNetworkMessage.cs @@ -49,7 +49,7 @@ public void SendScore(int score, Vector3 scorePos, int lives) }; // also send to host player so we can update ui - Server.SendToAll(msg, excludeLocalPlayer: false); + Server.SendToAll(msg, authenticatedOnly: true, excludeLocalPlayer: false); } } // CodeEmbed-End: send-score diff --git a/Assets/Tests/Runtime/ClientServerSendTo.cs b/Assets/Tests/Runtime/ClientServerSendTo.cs index fc4b12b220..769ea3b235 100644 --- a/Assets/Tests/Runtime/ClientServerSendTo.cs +++ b/Assets/Tests/Runtime/ClientServerSendTo.cs @@ -31,7 +31,7 @@ protected override UniTask LateSetup() [UnityTest] public IEnumerator SendToAll([Values(true, false)] bool excludeLocal) { - server.SendToAll(new TestMessage(), excludeLocal); + server.SendToAll(new TestMessage(), authenticatedOnly: true, excludeLocal); yield return null; for (var i = 0; i < RemoteClientCount; i++) diff --git a/Assets/Tests/Runtime/HostSendTo.cs b/Assets/Tests/Runtime/HostSendTo.cs index f9590ffb15..e05bf6f43d 100644 --- a/Assets/Tests/Runtime/HostSendTo.cs +++ b/Assets/Tests/Runtime/HostSendTo.cs @@ -48,7 +48,7 @@ protected override UniTask LateSetup() [UnityTest] public IEnumerator SendToAll([Values(true, false)] bool excludeLocal) { - server.SendToAll(new TestMessage(), excludeLocal); + server.SendToAll(new TestMessage(), authenticatedOnly: true, excludeLocal); yield return null; for (var i = 0; i < ClientCount; i++) diff --git a/Assets/Tests/Runtime/SendToAllocations.cs b/Assets/Tests/Runtime/SendToAllocations.cs index 0da17ad36c..533112432f 100644 --- a/Assets/Tests/Runtime/SendToAllocations.cs +++ b/Assets/Tests/Runtime/SendToAllocations.cs @@ -48,7 +48,7 @@ public void ShouldNotAllocate([Values(true, false)] bool excludeLocal) { TestAllocation(() => { - server.SendToAll(new TestMessage(), excludeLocal); + server.SendToAll(new TestMessage(), authenticatedOnly: true, excludeLocal); }); }