fix(MemoryTransport): Implemented OnServerConnectedWithAddress

This commit is contained in:
MrGadget 2024-07-11 11:26:00 -04:00
parent 9099b420a9
commit e6f2768aaa
2 changed files with 10 additions and 10 deletions

View File

@ -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)}");

View File

@ -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));