mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2026-08-15 13:04:36 +00:00
Fix offline LAN encrypted login
This commit is contained in:
parent
5f0ca8837f
commit
4bbc751cc1
3 changed files with 42 additions and 2 deletions
|
|
@ -228,6 +228,7 @@ namespace MinecraftClient
|
|||
SessionToken _sessionToken;
|
||||
CancellationTokenSource? cmdprompt = null;
|
||||
Tuple<Thread, CancellationTokenSource>? timeoutdetector = null;
|
||||
private Thread? basicIOReadThread;
|
||||
private int transferInProgress = 0;
|
||||
private bool consoleReadThreadOwned = false;
|
||||
private bool consoleHandlersAttached = false;
|
||||
|
|
@ -527,6 +528,23 @@ namespace MinecraftClient
|
|||
{
|
||||
cmdprompt = new CancellationTokenSource();
|
||||
|
||||
if (ConsoleIO.BasicIO || ConsoleIO.Backend is null)
|
||||
{
|
||||
if (!consoleReadThreadOwned)
|
||||
{
|
||||
CancellationToken token = cmdprompt.Token;
|
||||
basicIOReadThread = new Thread(() => BasicIOReadLoop(token))
|
||||
{
|
||||
IsBackground = true,
|
||||
Name = "MCC BasicIO read thread"
|
||||
};
|
||||
basicIOReadThread.Start();
|
||||
consoleReadThreadOwned = true;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!consoleReadThreadOwned)
|
||||
{
|
||||
ConsoleIO.Backend.BeginReadThread();
|
||||
|
|
@ -543,6 +561,15 @@ namespace MinecraftClient
|
|||
|
||||
private void StopConsoleSession()
|
||||
{
|
||||
if (ConsoleIO.BasicIO || ConsoleIO.Backend is null)
|
||||
{
|
||||
cmdprompt?.Cancel();
|
||||
basicIOReadThread = null;
|
||||
consoleReadThreadOwned = false;
|
||||
consoleHandlersAttached = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (consoleHandlersAttached)
|
||||
{
|
||||
ConsoleIO.Backend.MessageReceived -= ConsoleReaderOnMessageReceived;
|
||||
|
|
@ -557,6 +584,19 @@ namespace MinecraftClient
|
|||
}
|
||||
}
|
||||
|
||||
private void BasicIOReadLoop(CancellationToken token)
|
||||
{
|
||||
while (!token.IsCancellationRequested)
|
||||
{
|
||||
string? input = Console.ReadLine();
|
||||
if (input is null)
|
||||
return;
|
||||
|
||||
if (!token.IsCancellationRequested)
|
||||
ConsoleReaderOnMessageReceived(this, input);
|
||||
}
|
||||
}
|
||||
|
||||
private void ResetStateForTransfer()
|
||||
{
|
||||
ClearTasks();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue