Skip to content

Commit

Permalink
Added rough exception handling for socket connection
Browse files Browse the repository at this point in the history
  • Loading branch information
stenlan committed Oct 11, 2020
1 parent 11e6628 commit 356c3be
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 3 deletions.
Binary file modified .vs/slnx.sqlite
Binary file not shown.
11 changes: 11 additions & 0 deletions AmongUsCapture/ClientSocket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,24 @@ public void OnTokenHandler(object sender, StartToken token)
}
}

private void OnConnectionFailure(AggregateException? e)
{
string message = e != null ? e.Message : "A generic connection error occured.";
Settings.conInterface.WriteModuleTextColored("ClientSocket", Color.Cyan, $"{Color.Red.ToTextColor()}{message}");
}

private void Connect(string url, string connectCode)
{
try
{
socket.ServerUri = new Uri(url);
socket.ConnectAsync().ContinueWith(t =>
{
if (!t.IsCompletedSuccessfully)
{
OnConnectionFailure(t.Exception);
return;
}
OnConnected?.Invoke(this, EventArgs.Empty);
SendConnectCode(connectCode);
});
Expand Down
1 change: 0 additions & 1 deletion AmongUsCapture/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
using System.Threading.Tasks;
using System.Windows.Forms;
using Microsoft.Win32;
using System.Threading.Tasks;

namespace AmongUsCapture
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
<PublishDir>bin\publish\32Bit\</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<TargetFramework>netcoreapp3.1</TargetFramework>
<RuntimeIdentifier>win-x86</RuntimeIdentifier>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<SelfContained>false</SelfContained>
<PublishSingleFile>True</PublishSingleFile>
<PublishReadyToRun>True</PublishReadyToRun>
Expand Down
1 change: 0 additions & 1 deletion AmongUsCapture/UserForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,6 @@ private void doConnect(string url)
{
clientSocket.OnConnected += (sender, e) =>
{
Settings.PersistentSettings.host = url;
};

Expand Down

0 comments on commit 356c3be

Please sign in to comment.