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.
This commit is contained in:
PJB3005
2025-08-07 00:44:06 +02:00
parent a1cdd60602
commit 07fbd5263c
2 changed files with 5 additions and 4 deletions

View File

@@ -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

View File

@@ -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)
{