com.unity.netcode.gameobjects@1.0.0-pre.9

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.9] - 2022-05-10

### Fixed

- Fixed Hosting again after failing to host now works correctly (#1938)
- Fixed NetworkManager to cleanup connected client lists after stopping (#1945)
- Fixed NetworkHide followed by NetworkShow on the same frame works correctly (#1940)
This commit is contained in:
Unity Technologies
2022-05-10 00:00:00 +00:00
parent add668dfd2
commit 5b1fc203ed
10 changed files with 143 additions and 30 deletions

View File

@@ -53,9 +53,21 @@ namespace Unity.Netcode
public uint TickRate = 30;
/// <summary>
/// The amount of seconds to wait for handshake to complete before timing out a client
/// The amount of seconds for the server to wait for the connection approval handshake to complete before the client is disconnected.
///
/// If the timeout is reached before approval is completed the client will be disconnected.
/// </summary>
[Tooltip("The amount of seconds to wait for the handshake to complete before the client times out")]
/// <remarks>
/// The period begins after the <see cref="NetworkEvent.Connect"/> is received on the server.
/// The period ends once the server finishes processing a <see cref="ConnectionRequestMessage"/> from the client.
///
/// This setting is independent of any Transport-level timeouts that may be in effect. It covers the time between
/// the connection being established on the Transport layer, the client sending a
/// <see cref="ConnectionRequestMessage"/>, and the server processing that message through <see cref="ConnectionApproval"/>.
///
/// This setting is server-side only.
/// </remarks>
[Tooltip("The amount of seconds for the server to wait for the connection approval handshake to complete before the client is disconnected")]
public int ClientConnectionBufferTimeout = 10;
/// <summary>

View File

@@ -765,12 +765,7 @@ namespace Unity.Netcode
#endif
LocalClientId = ulong.MaxValue;
PendingClients.Clear();
m_ConnectedClients.Clear();
m_ConnectedClientsList.Clear();
m_ConnectedClientIds.Clear();
LocalClient = null;
NetworkObject.OrphanChildren.Clear();
ClearClients();
// Create spawn manager instance
SpawnManager = new NetworkSpawnManager(this);
@@ -862,6 +857,16 @@ namespace Unity.Netcode
NetworkConfig.NetworkTransport.Initialize(this);
}
private void ClearClients()
{
PendingClients.Clear();
m_ConnectedClients.Clear();
m_ConnectedClientsList.Clear();
m_ConnectedClientIds.Clear();
LocalClient = null;
NetworkObject.OrphanChildren.Clear();
}
/// <summary>
/// Starts a server
/// </summary>
@@ -1175,6 +1180,8 @@ namespace Unity.Netcode
m_ShuttingDown = true;
m_StopProcessingMessages = discardMessageQueue;
}
NetworkConfig.NetworkTransport.OnTransportEvent -= HandleRawTransportPoll;
}
internal void ShutdownInternal()
@@ -1299,6 +1306,8 @@ namespace Unity.Netcode
IsListening = false;
m_ShuttingDown = false;
m_StopProcessingMessages = false;
ClearClients();
}
// INetworkUpdateSystem

View File

@@ -352,7 +352,10 @@ namespace Unity.Netcode
if (NetworkManager != null && NetworkManager.SpawnManager != null &&
NetworkManager.SpawnManager.SpawnedObjects.TryGetValue(NetworkObjectId, out var networkObject))
{
NetworkManager.SpawnManager.OnDespawnObject(networkObject, false);
if (this == networkObject)
{
NetworkManager.SpawnManager.OnDespawnObject(networkObject, false);
}
}
}

View File

@@ -11,6 +11,7 @@ namespace Unity.Netcode
public class NetworkList<T> : NetworkVariableSerialization<T> where T : unmanaged, IEquatable<T>
{
private NativeList<T> m_List = new NativeList<T>(64, Allocator.Persistent);
private NativeList<T> m_ListAtLastReset = new NativeList<T>(64, Allocator.Persistent);
private NativeList<NetworkListEvent<T>> m_DirtyEvents = new NativeList<NetworkListEvent<T>>(64, Allocator.Persistent);
/// <summary>
@@ -41,7 +42,11 @@ namespace Unity.Netcode
public override void ResetDirty()
{
base.ResetDirty();
m_DirtyEvents.Clear();
if (m_DirtyEvents.Length > 0)
{
m_DirtyEvents.Clear();
m_ListAtLastReset.CopyFrom(m_List);
}
}
/// <inheritdoc />
@@ -109,10 +114,10 @@ namespace Unity.Netcode
/// <inheritdoc />
public override void WriteField(FastBufferWriter writer)
{
writer.WriteValueSafe((ushort)m_List.Length);
for (int i = 0; i < m_List.Length; i++)
writer.WriteValueSafe((ushort)m_ListAtLastReset.Length);
for (int i = 0; i < m_ListAtLastReset.Length; i++)
{
Write(writer, m_List[i]);
Write(writer, m_ListAtLastReset[i]);
}
}
@@ -454,6 +459,7 @@ namespace Unity.Netcode
public override void Dispose()
{
m_List.Dispose();
m_ListAtLastReset.Dispose();
m_DirtyEvents.Dispose();
}
}

View File

@@ -1047,7 +1047,12 @@ namespace Unity.Netcode.Transports.UTP
return false;
}
return ClientBindAndConnect();
var succeeded = ClientBindAndConnect();
if (!succeeded)
{
Shutdown();
}
return succeeded;
}
public override bool StartServer()
@@ -1057,12 +1062,23 @@ namespace Unity.Netcode.Transports.UTP
return false;
}
bool succeeded;
switch (m_ProtocolType)
{
case ProtocolType.UnityTransport:
return ServerBindAndListen(ConnectionData.ListenEndPoint);
succeeded = ServerBindAndListen(ConnectionData.ListenEndPoint);
if (!succeeded)
{
Shutdown();
}
return succeeded;
case ProtocolType.RelayUnityTransport:
return StartRelayServer();
succeeded = StartRelayServer();
if (!succeeded)
{
Shutdown();
}
return succeeded;
default:
return false;
}