Fix Reset() not getting called if client channel disconnects unprompted.

Fixes https://github.com/space-wizards/RobustToolbox/issues/6390
Fixes https://github.com/space-wizards/RobustToolbox/issues/6388
This commit is contained in:
PJB3005
2026-01-20 19:03:32 +01:00
parent 2afef1480e
commit 89e16d5ba9

View File

@@ -144,6 +144,7 @@ namespace Robust.Shared.Network
private bool _clientSerializerComplete;
private bool _clientTransferComplete;
private bool _clientResetPending;
/// <inheritdoc />
public int Port => _config.GetCVar(CVars.NetPort);
@@ -420,6 +421,10 @@ namespace Robust.Shared.Network
public void Reset(string reason)
{
_logger.Info($"Resetting NetManager: {reason}");
_clientResetPending = false;
foreach (var kvChannel in _channels)
{
DisconnectChannel(kvChannel.Value, reason);
@@ -606,6 +611,9 @@ namespace Robust.Shared.Network
MessagesUnsentMetrics.Set(unsent);
MessagesStoredMetrics.Set(stored);
*/
if (_clientResetPending)
Reset("Channel closed");
}
/// <inheritdoc />
@@ -875,14 +883,7 @@ namespace Robust.Shared.Network
#endif
if (IsClient)
{
connection.Peer.Shutdown(reason);
_toCleanNetPeers.Add(connection.Peer);
_strings.Reset();
_cancelConnectTokenSource?.Cancel();
ClientConnectState = ClientConnectionState.NotConnecting;
}
_clientResetPending = true;
}
/// <inheritdoc />