From 07fbd5263cf968ee99169e69300973cc9b2f55bb Mon Sep 17 00:00:00 2001 From: PJB3005 Date: Thu, 7 Aug 2025 00:44:06 +0200 Subject: [PATCH] Run disconnect callbacks after removing channel from lists Similar to the previous changes to player sessions, but now one layer lower. Fixed ServerSendToAll from the relevant callbacks sending to a disconnected channel. --- RELEASE-NOTES.md | 2 +- Robust.Shared/Network/NetManager.cs | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index 4f4049f94..de22b007d 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -35,7 +35,7 @@ END TEMPLATE--> ### Breaking changes -*None yet* +* When a player disconnects, the relevant callbacks are now fired *after* removing the channel from `INetManager`. ### New features diff --git a/Robust.Shared/Network/NetManager.cs b/Robust.Shared/Network/NetManager.cs index 05ff33e9d..c38c63759 100644 --- a/Robust.Shared/Network/NetManager.cs +++ b/Robust.Shared/Network/NetManager.cs @@ -827,6 +827,10 @@ namespace Robust.Shared.Network _assignedUsernames.Remove(channel.UserName); _assignedUserIds.Remove(channel.UserId); + _channels.Remove(connection); + peer.RemoveChannel(channel); + channel.EncryptionChannel?.Complete(); + #if EXCEPTION_TOLERANCE try { @@ -842,9 +846,6 @@ namespace Robust.Shared.Network _logger.Error("Caught exception in OnDisconnected handler:\n{0}", e); } #endif - _channels.Remove(connection); - peer.RemoveChannel(channel); - channel.EncryptionChannel?.Complete(); if (IsClient) {