Skip to content

Commit

Permalink
Connection Test Messages box now modal
Browse files Browse the repository at this point in the history
  • Loading branch information
Morgyn committed May 14, 2024
1 parent 93fecc7 commit 297ad1a
Showing 1 changed file with 29 additions and 8 deletions.
37 changes: 29 additions & 8 deletions ConfigureForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ private void TestConnection_Click(object sender, EventArgs e)
{
if (!ushort.TryParse(port.Text, out ushort shortPort))
{
MessageBox.Show("Port must be below 65536", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
ConfigureForm.Instance.Invoke((MethodInvoker)delegate {
MessageBox.Show(this, "Port must be below 65536", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);;
});
return;
}

Expand Down Expand Up @@ -160,7 +162,10 @@ private void TestOnConnect(object sender, EventArgs e)
OBSwsTest.Disconnect();
}
Log("OBS Test Connected to OBS");
MessageBox.Show("Test OK!", "Connection test");
ConfigureForm.Instance.Invoke((MethodInvoker)delegate {
MessageBox.Show(this, "Test OK!", "Connection test");
});


OBSwsTest.Disconnect();
}
Expand All @@ -181,14 +186,18 @@ private void TestOnDisconnect(object sender, OBSWebsocketDotNet.Communication.Ob

if (e.ObsCloseCode == OBSWebsocketDotNet.Communication.ObsCloseCodes.AuthenticationFailed)
{
MessageBox.Show("Wrong password.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
ConfigureForm.Instance.Invoke((MethodInvoker)delegate {
MessageBox.Show(this, "Wrong password.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
});
return;
}
else if (e.WebsocketDisconnectionInfo != null)
{
if (e.WebsocketDisconnectionInfo.Exception != null)
{
MessageBox.Show($"Connection failed: CloseCode: {e.ObsCloseCode} Desc: {e.WebsocketDisconnectionInfo?.CloseStatusDescription} Exception:{e.WebsocketDisconnectionInfo?.Exception?.Message}\nType: {e.WebsocketDisconnectionInfo.Type}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
ConfigureForm.Instance.Invoke((MethodInvoker)delegate {
MessageBox.Show(this, $"Connection failed: CloseCode: {e.ObsCloseCode} Desc: {e.WebsocketDisconnectionInfo?.CloseStatusDescription} Exception:{e.WebsocketDisconnectionInfo?.Exception?.Message}\nType: {e.WebsocketDisconnectionInfo.Type}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
});
}
else
{
Expand All @@ -198,15 +207,24 @@ private void TestOnDisconnect(object sender, OBSWebsocketDotNet.Communication.Ob
return;
if (e.WebsocketDisconnectionInfo.Type == Websocket.Client.DisconnectionType.Error)
{
MessageBox.Show($"{e.WebsocketDisconnectionInfo?.CloseStatusDescription}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
ConfigureForm.Instance.Invoke((MethodInvoker)delegate
{
MessageBox.Show(this, $"{e.WebsocketDisconnectionInfo?.CloseStatusDescription}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
});
return;
}
MessageBox.Show($"Connection failed: CloseCode: {e.ObsCloseCode}\n Desc: {e.WebsocketDisconnectionInfo?.CloseStatusDescription}\nType: {e.WebsocketDisconnectionInfo.Type}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
ConfigureForm.Instance.Invoke((MethodInvoker)delegate
{
MessageBox.Show(ConfigureForm.Instance, $"Connection failed: CloseCode: {e.ObsCloseCode}\n Desc: {e.WebsocketDisconnectionInfo?.CloseStatusDescription}\nType: {e.WebsocketDisconnectionInfo.Type}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
});
}
}
else
{
MessageBox.Show($"Connection failed: CloseCode: {e.ObsCloseCode}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
ConfigureForm.Instance.Invoke((MethodInvoker)delegate
{
MessageBox.Show(this, $"Connection failed: CloseCode: {e.ObsCloseCode}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
});
return;
}
}
Expand All @@ -216,7 +234,10 @@ private void TestConnectionTimerEventProcessor(object sender, EventArgs e)
if (sender is Timer timer)
{
timer.Dispose();
MessageBox.Show("Test timed out", "Connection test");
ConfigureForm.Instance.Invoke((MethodInvoker)delegate
{
MessageBox.Show(this, "Test timed out", "Connection test");
});
Log("Connection timed out waiting for handshake OBS Test");
OBSwsTest.Disconnect();
}
Expand Down

0 comments on commit 297ad1a

Please sign in to comment.