The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). Additional documentation and release notes are available at [Multiplayer Documentation](https://docs-multiplayer.unity3d.com). ## [1.0.0-pre.8] - 2022-04-27 ### Changed - `unmanaged` structs are no longer universally accepted as RPC parameters because some structs (i.e., structs with pointers in them, such as `NativeList<T>`) can't be supported by the default memcpy struct serializer. Structs that are intended to be serialized across the network must add `INetworkSerializeByMemcpy` to the interface list (i.e., `struct Foo : INetworkSerializeByMemcpy`). This interface is empty and just serves to mark the struct as compatible with memcpy serialization. For external structs you can't edit, you can pass them to RPCs by wrapping them in `ForceNetworkSerializeByMemcpy<T>`. (#1901) ### Removed - Removed `SIPTransport` (#1870) - Removed `ClientNetworkTransform` from the package samples and moved to Boss Room's Utilities package which can be found [here](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Packages/com.unity.multiplayer.samples.coop/Utilities/Net/ClientAuthority/ClientNetworkTransform.cs). ### Fixed - Fixed `NetworkTransform` generating false positive rotation delta checks when rolling over between 0 and 360 degrees. (#1890) - Fixed client throwing an exception if it has messages in the outbound queue when processing the `NetworkEvent.Disconnect` event and is using UTP. (#1884) - Fixed issue during client synchronization if 'ValidateSceneBeforeLoading' returned false it would halt the client synchronization process resulting in a client that was approved but not synchronized or fully connected with the server. (#1883) - Fixed an issue where UNetTransport.StartServer would return success even if the underlying transport failed to start (#854) - Passing generic types to RPCs no longer causes a native crash (#1901) - Fixed an issue where calling `Shutdown` on a `NetworkManager` that was already shut down would cause an immediate shutdown the next time it was started (basically the fix makes `Shutdown` idempotent). (#1877)
89 lines
3.5 KiB
C#
89 lines
3.5 KiB
C#
#if MULTIPLAYER_TOOLS
|
|
#if MULTIPLAYER_TOOLS_1_0_0_PRE_7
|
|
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using NUnit.Framework;
|
|
using Unity.Collections;
|
|
using Unity.Multiplayer.Tools.MetricTypes;
|
|
using UnityEngine.TestTools;
|
|
using Unity.Netcode.TestHelpers.Runtime;
|
|
using Unity.Netcode.TestHelpers.Runtime.Metrics;
|
|
|
|
namespace Unity.Netcode.RuntimeTests.Metrics
|
|
{
|
|
/// <summary>
|
|
/// Note: This is one way to easily identify each specific test.
|
|
/// Since the test only tested 1 and then 2 clients, I made this
|
|
/// and enum, but you can always remove the enum in the constructor,
|
|
/// replace it with an int, and then test from 1 to 9 clients.
|
|
/// Just an example of how you can accomplish the same task using
|
|
/// the NetcodeIntegrationTest
|
|
/// </summary>
|
|
[TestFixture(ClientCount.OneClient)]
|
|
[TestFixture(ClientCount.TwoClients)]
|
|
internal class RttMetricsTests : NetcodeIntegrationTest
|
|
{
|
|
protected override int NumberOfClients => m_ClientCount;
|
|
|
|
public enum ClientCount
|
|
{
|
|
OneClient,
|
|
TwoClients
|
|
}
|
|
|
|
private int m_ClientCount;
|
|
|
|
public RttMetricsTests(ClientCount numberOfClients)
|
|
{
|
|
m_ClientCount = numberOfClients == ClientCount.OneClient ? 1 : 2;
|
|
}
|
|
|
|
[UnityTest]
|
|
public IEnumerator TrackRttMetricServerToClient()
|
|
{
|
|
var waitForMetricValues = new WaitForGaugeMetricValues((m_ServerNetworkManager.NetworkMetrics as NetworkMetrics).Dispatcher, NetworkMetricTypes.RttToServer);
|
|
|
|
using (var writer = new FastBufferWriter(sizeof(uint), Allocator.Temp))
|
|
{
|
|
writer.WriteValueSafe(1337);
|
|
m_ServerNetworkManager.CustomMessagingManager.SendUnnamedMessageToAll(writer);
|
|
}
|
|
|
|
yield return WaitForConditionOrTimeOut(() => waitForMetricValues.MetricFound());
|
|
Assert.False(s_GlobalTimeoutHelper.TimedOut, $"{nameof(TrackRttMetricServerToClient)} timed out waiting for metric to be found for {m_ClientCount} clients!");
|
|
|
|
var rttValue = waitForMetricValues.AssertMetricValueHaveBeenFound();
|
|
Assert.AreEqual(0f, rttValue);
|
|
}
|
|
|
|
[UnityTest]
|
|
public IEnumerator TrackRttMetricClientToServer()
|
|
{
|
|
var clientGaugeMetricValues = new List<WaitForGaugeMetricValues>();
|
|
foreach (var client in m_ClientNetworkManagers)
|
|
{
|
|
clientGaugeMetricValues.Add(new WaitForGaugeMetricValues((client.NetworkMetrics as NetworkMetrics).Dispatcher, NetworkMetricTypes.RttToServer, metric => metric > 0f));
|
|
}
|
|
|
|
using (var writer = new FastBufferWriter(sizeof(uint), Allocator.Temp))
|
|
{
|
|
writer.WriteValueSafe(1337);
|
|
m_ServerNetworkManager.CustomMessagingManager.SendUnnamedMessageToAll(writer);
|
|
}
|
|
|
|
yield return WaitForConditionOrTimeOut(() => clientGaugeMetricValues.Where((c) => c.MetricFound()).Count() == NumberOfClients);
|
|
Assert.False(s_GlobalTimeoutHelper.TimedOut, $"{nameof(TrackRttMetricClientToServer)} timed out waiting for metric to be found for {m_ClientCount} clients!");
|
|
|
|
foreach (var clientGaugeMetricValue in clientGaugeMetricValues)
|
|
{
|
|
var rttValue = clientGaugeMetricValue.AssertMetricValueHaveBeenFound();
|
|
Assert.That(rttValue, Is.GreaterThanOrEqualTo(1e-3f));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
#endif
|
|
#endif
|