Add cookie snapshotting during connection transfer

Snapshot cookies before disposing of the old handler and restore them for the new connection.
This commit is contained in:
xiaoze_qwq_ 2026-08-26 12:14:55 +08:00 committed by GitHub
parent 6a5b28b0bd
commit 9b96873d87
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -442,6 +442,9 @@ namespace MinecraftClient
ResetStateForTransfer();
// Snapshot cookies before Dispose clears them
Dictionary<string, byte[]> savedCookies = new Dictionary<string, byte[]>(Cookies);
// Retire the old handler so its updater exits without reporting a stale disconnect.
oldHandler.Dispose();
oldClient.Close();
@ -457,6 +460,7 @@ namespace MinecraftClient
// Reinitialize the protocol handler
handler = Protocol.ProtocolHandler.GetProtocolHandler(client, protocolversion, null, this);
Cookies = savedCookies; // Restore cookies for the new connection before login
Log.Info($"Connected to {resolvedHost}:{resolvedPort}");
// Retry login process