From 8f6b01b0f47b184eed74c070f4bab8cd1c5cd71d Mon Sep 17 00:00:00 2001 From: MrGadget <9826063+MrGadget1024@users.noreply.github.com> Date: Thu, 11 Jul 2024 11:26:00 -0400 Subject: [PATCH] fix(MemoryTransport): Implemented OnServerConnectedWithAddress --- Assets/Mirror/Tests/Common/MemoryTransport.cs | 2 +- .../Editor/NetworkServer/NetworkServerTest.cs | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Assets/Mirror/Tests/Common/MemoryTransport.cs b/Assets/Mirror/Tests/Common/MemoryTransport.cs index 82760a161..3c9ed6f14 100644 --- a/Assets/Mirror/Tests/Common/MemoryTransport.cs +++ b/Assets/Mirror/Tests/Common/MemoryTransport.cs @@ -201,7 +201,7 @@ public override void ServerEarlyUpdate() case EventType.Connected: Debug.Log("MemoryTransport Server Message: Connected"); // event might be null in tests if no NetworkClient is used. - OnServerConnected?.Invoke(message.connectionId); + OnServerConnectedWithAddress?.Invoke(message.connectionId, ""); break; case EventType.Data: Debug.Log($"MemoryTransport Server Message: Data: {BitConverter.ToString(message.data)}"); diff --git a/Assets/Mirror/Tests/Editor/NetworkServer/NetworkServerTest.cs b/Assets/Mirror/Tests/Editor/NetworkServer/NetworkServerTest.cs index 939fe010d..5a9b943b7 100644 --- a/Assets/Mirror/Tests/Editor/NetworkServer/NetworkServerTest.cs +++ b/Assets/Mirror/Tests/Editor/NetworkServer/NetworkServerTest.cs @@ -67,12 +67,12 @@ public void MaxConnections() Assert.That(NetworkServer.connections.Count, Is.EqualTo(0)); // connect first: should work - transport.OnServerConnected.Invoke(42); + transport.OnServerConnectedWithAddress.Invoke(42, ""); Assert.That(NetworkServer.connections.Count, Is.EqualTo(1)); // connect second: should fail LogAssert.ignoreFailingMessages = true; - transport.OnServerConnected.Invoke(43); + transport.OnServerConnectedWithAddress.Invoke(43, ""); LogAssert.ignoreFailingMessages = false; Assert.That(NetworkServer.connections.Count, Is.EqualTo(1)); } @@ -86,7 +86,7 @@ public void OnConnectedEventCalled() // listen & connect NetworkServer.Listen(1); - transport.OnServerConnected.Invoke(42); + transport.OnServerConnectedWithAddress.Invoke(42, ""); Assert.That(connectCalled, Is.True); } @@ -99,7 +99,7 @@ public void OnDisconnectedEventCalled() // listen & connect NetworkServer.Listen(1); - transport.OnServerConnected.Invoke(42); + transport.OnServerConnectedWithAddress.Invoke(42, ""); // disconnect transport.OnServerDisconnected.Invoke(42); @@ -114,12 +114,12 @@ public void ConnectionsDict() Assert.That(NetworkServer.connections.Count, Is.EqualTo(0)); // connect first - transport.OnServerConnected.Invoke(42); + transport.OnServerConnectedWithAddress.Invoke(42, ""); Assert.That(NetworkServer.connections.Count, Is.EqualTo(1)); Assert.That(NetworkServer.connections.ContainsKey(42), Is.True); // connect second - transport.OnServerConnected.Invoke(43); + transport.OnServerConnectedWithAddress.Invoke(43, ""); Assert.That(NetworkServer.connections.Count, Is.EqualTo(2)); Assert.That(NetworkServer.connections.ContainsKey(43), Is.True); @@ -146,7 +146,7 @@ public void OnConnectedOnlyAllowsNonZeroConnectionIds() // connect with connectionId == 0 should fail // (it will show an error message, which is expected) LogAssert.ignoreFailingMessages = true; - transport.OnServerConnected.Invoke(0); + transport.OnServerConnectedWithAddress.Invoke(0, ""); Assert.That(NetworkServer.connections.Count, Is.EqualTo(0)); LogAssert.ignoreFailingMessages = false; } @@ -158,13 +158,13 @@ public void ConnectDuplicateConnectionIds() NetworkServer.Listen(2); // connect first - transport.OnServerConnected.Invoke(42); + transport.OnServerConnectedWithAddress.Invoke(42, ""); Assert.That(NetworkServer.connections.Count, Is.EqualTo(1)); NetworkConnectionToClient original = NetworkServer.connections[42]; // connect duplicate - shouldn't overwrite first one LogAssert.ignoreFailingMessages = true; - transport.OnServerConnected.Invoke(42); + transport.OnServerConnectedWithAddress.Invoke(42, ""); LogAssert.ignoreFailingMessages = false; Assert.That(NetworkServer.connections.Count, Is.EqualTo(1)); Assert.That(NetworkServer.connections[42], Is.EqualTo(original));