Skip to content

Commit 5342fcb

Browse files
Merge develop-2.0.0 into refactor/minor-unity-transport-cleanup
2 parents 9ab12dc + 78cad42 commit 5342fcb

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

com.unity.netcode.gameobjects/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Additional documentation and release notes are available at [Multiplayer Documen
2222

2323
### Fixed
2424

25+
- Fixed an issue in `UnityTransport` where the transport would accept sends on invalid connections, leading to a useless memory allocation and confusing error message. (#3382)
2526
- Fixed issue where the time delta that interpolators used would not be properly updated during multiple fixed update invocations within the same player loop frame. (#3355)
2627
- Fixed issue when using a distributed authority network topology and many clients attempt to connect simultaneously the session owner could max-out the maximum in-flight reliable messages allowed, start dropping packets, and some of the connecting clients would fail to fully synchronize. (#3350)
2728
- Fixed issue when using a distributed authority network topology and scene management was disabled clients would not be able to spawn any new network prefab instances until synchronization was complete. (#3350)

com.unity.netcode.gameobjects/Runtime/Transports/UTP/UnityTransport.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1282,8 +1282,13 @@ public override NetcodeEvent PollEvent(out ulong clientId, out ArraySegment<byte
12821282
/// <param name="networkDelivery">The delivery type (QoS) to send data with</param>
12831283
public override void Send(ulong clientId, ArraySegment<byte> payload, NetworkDelivery networkDelivery)
12841284
{
1285-
var pipeline = SelectSendPipeline(networkDelivery);
1285+
var connection = ParseClientId(clientId);
1286+
if (!m_Driver.IsCreated || m_Driver.GetConnectionState(connection) != NetworkConnection.State.Connected)
1287+
{
1288+
return;
1289+
}
12861290

1291+
var pipeline = SelectSendPipeline(networkDelivery);
12871292
if (pipeline != m_ReliableSequencedPipeline && payload.Count > m_MaxPayloadSize)
12881293
{
12891294
Debug.LogError($"Unreliable payload of size {payload.Count} larger than configured 'Max Payload Size' ({m_MaxPayloadSize}).");

com.unity.netcode.gameobjects/Tests/Runtime/Transports/UnityTransportTests.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,5 +485,22 @@ public IEnumerator DoesNotActAfterShutdown([Values] AfterShutdownAction afterShu
485485
yield return EnsureNoNetworkEvent(m_Client1Events);
486486
}
487487
}
488+
489+
[UnityTest]
490+
public IEnumerator DoesNotAttemptToSendOnInvalidConnections()
491+
{
492+
InitializeTransport(out m_Server, out m_ServerEvents);
493+
InitializeTransport(out m_Client1, out m_Client1Events);
494+
495+
m_Server.StartServer();
496+
m_Client1.StartClient();
497+
498+
yield return WaitForNetworkEvent(NetworkEvent.Connect, m_Client1Events);
499+
500+
var data = new ArraySegment<byte>(new byte[42]);
501+
m_Server.Send(0, data, NetworkDelivery.Reliable);
502+
503+
yield return EnsureNoNetworkEvent(m_Client1Events);
504+
}
488505
}
489506
}

0 commit comments

Comments
 (0)