Skip to content

Commit

Permalink
don't error out when already connected
Browse files Browse the repository at this point in the history
can't believe i have to fix the worlds most in-flames garbage again
  • Loading branch information
yellows111 committed May 26, 2024
1 parent 9ecf9e0 commit e4c0659
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ public Form1()
private string hcaptchakey = null;
private JObject tokens;
private bool loggedIn = false;
private bool wasConnectedSuccessfully = false;

private void Form1_Load(object sender, EventArgs e)
{
Expand Down Expand Up @@ -598,6 +599,7 @@ user arg[2] is now arg[3]

case "1": {
Console.WriteLine("Connected successfully to "+Globals.vmname+" on "+Globals.vmip+".");
wasConnectedSuccessfully = true;
break;
}

Expand Down Expand Up @@ -677,12 +679,16 @@ private void Socket_OnOpen(object sender, EventArgs e)

private void Socket_OnClose(object sender, WebSocketCloseEventArgs e)
{
if (e.Reason == WebSocketCloseReason.Error)
{
MessageBox.Show("Failed to connect to the VM.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
Close();
Application.Exit();
}

if(wasConnectedSuccessfully == false ) {
if (e.Reason == WebSocketCloseReason.Error)
{
MessageBox.Show("Failed to connect to the VM.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
Close();
Application.Exit();
}
// if we're here, we're failed for some reason in pre-connect?
}
else
{
g.FillRectangle(new SolidBrush(Color.Black),0,0,pictureBox1.Width,pictureBox1.Height);
Expand Down

0 comments on commit e4c0659

Please sign in to comment.