From: miniduikboot Date: Sun, 26 May 2024 20:05:21 +0000 (+0200) Subject: Clean up clients that refuse to quit properly X-Git-Tag: v1.9.2~1^2 X-Git-Url: https://git.deb.at/?a=commitdiff_plain;h=661421da5a30b3f57a1490d6d2c35898495ba5aa;p=rhonda%2Fimpostor.git Clean up clients that refuse to quit properly When a player is kicked or banned from a game, the client is expected to disconnect in response. When they decide not to *or* the disconnect packet is lost, Impostor just silently disposes of the connection. This does not remove them from ClientManager, which is how I tracked this bug down. By sending them a proper disconnect message, clients should have received *a* disconnection message before dropping their connection. Future work should split this entire method in removing players from a game and processing kick/bans because the latter feature is not relevant for other callers of this method. --- diff --git a/src/Impostor.Server/Net/State/Game.State.cs b/src/Impostor.Server/Net/State/Game.State.cs index b8fcd2e..e570c98 100644 --- a/src/Impostor.Server/Net/State/Game.State.cs +++ b/src/Impostor.Server/Net/State/Game.State.cs @@ -81,7 +81,7 @@ namespace Impostor.Server.Net.State if (player.Client.Connection.IsConnected && player.Client.Connection is HazelConnection hazel) { _logger.LogInformation("{0} - Player {1} ({2}) kept connection open after leaving, disposing.", Code, player.Client.Name, playerId); - hazel.DisposeInnerConnection(); + await player.Client.DisconnectAsync(isBan ? DisconnectReason.Banned : DisconnectReason.Kicked); } });