mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-11-07 17:36:07 +00:00
Fix Unhandled WebException
This commit fixes an unhandled WebException that may occur when attempting to connect to the Minecraft session server when it is very slow or unreachable.
This commit is contained in:
parent
1284017245
commit
0e2ccdd1f6
1 changed files with 13 additions and 1 deletions
|
|
@ -79,7 +79,19 @@ namespace MinecraftClient
|
|||
Console.ForegroundColor = ConsoleColor.DarkGray;
|
||||
WebClient client = new WebClient();
|
||||
Console.Write("http://session.minecraft.net/game/joinserver.jsp?user=" + user + "&sessionId=" + sessionID + "&serverId=" + hash + " ... ");
|
||||
string result = client.DownloadString("http://session.minecraft.net/game/joinserver.jsp?user=" + user + "&sessionId=" + sessionID + "&serverId=" + hash);
|
||||
string result;
|
||||
try
|
||||
{
|
||||
result = client.DownloadString("http://session.minecraft.net/game/joinserver.jsp?user=" + user + "&sessionId=" + sessionID + "&serverId=" + hash);
|
||||
}
|
||||
catch (WebException e)
|
||||
{
|
||||
Console.ForegroundColor = ConsoleColor.Gray;
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("Error while connecting to session server: " + e.Message);
|
||||
Console.ForegroundColor = ConsoleColor.DarkGray;
|
||||
return false;
|
||||
}
|
||||
Console.WriteLine(result);
|
||||
Console.ForegroundColor = ConsoleColor.Gray;
|
||||
return (result == "OK");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue