mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
Fix AutoRelog running twice on disconnection
Bug introduced in commit aaf1e8311b
Implement User-Initiated logout reason to ignore the second logout event
See #817
This commit is contained in:
parent
94e96b11dd
commit
52d98538b3
3 changed files with 35 additions and 24 deletions
|
|
@ -349,12 +349,12 @@ namespace MinecraftClient
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Disconnect the client from the server
|
||||
/// Disconnect the client from the server (initiated from MCC)
|
||||
/// </summary>
|
||||
public void Disconnect()
|
||||
{
|
||||
foreach (ChatBot bot in bots.ToArray())
|
||||
bot.OnDisconnect(ChatBot.DisconnectReason.ConnectionLost, "Disconnected");
|
||||
bot.OnDisconnect(ChatBot.DisconnectReason.UserLogout, "");
|
||||
|
||||
botsOnHold.Clear();
|
||||
botsOnHold.AddRange(bots);
|
||||
|
|
@ -721,7 +721,7 @@ namespace MinecraftClient
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// When connection has been lost
|
||||
/// When connection has been lost, login was denied or played was kicked from the server
|
||||
/// </summary>
|
||||
public void OnConnectionLost(ChatBot.DisconnectReason reason, string message)
|
||||
{
|
||||
|
|
@ -751,6 +751,9 @@ namespace MinecraftClient
|
|||
ConsoleIO.WriteLine("Login failed :");
|
||||
ConsoleIO.WriteLineFormatted(message);
|
||||
break;
|
||||
|
||||
case ChatBot.DisconnectReason.UserLogout:
|
||||
throw new InvalidOperationException("User-initiated logout should be done by calling Disconnect()");
|
||||
}
|
||||
|
||||
foreach (ChatBot bot in bots.ToArray())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue