diff --git a/CollabVMSharp/CollabVMClient.cs b/CollabVMSharp/CollabVMClient.cs index a0467e4..9f9972e 100644 --- a/CollabVMSharp/CollabVMClient.cs +++ b/CollabVMSharp/CollabVMClient.cs @@ -1,20 +1,19 @@ #nullable enable #pragma warning disable CS4014 +using SixLabors.ImageSharp; +using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Net; using System.Net.WebSockets; -using System.Numerics; using System.Security.Authentication; using System.Text; using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; -using SixLabors.ImageSharp; -using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; using Timer = System.Timers.Timer; // ReSharper disable FieldCanBeMadeReadOnly.Local // ReSharper disable ArrangeObjectCreationWhenTypeNotEvident @@ -64,7 +63,6 @@ public class CollabVMClient { public event EventHandler ChatHistory; public event EventHandler ConnectedToNode; public event EventHandler NodeConnectFailed; - public event EventHandler ConnectionFailed; public event EventHandler Rect; public event EventHandler ScreenSize; public event EventHandler Renamed; @@ -132,7 +130,6 @@ public class CollabVMClient { ChatHistory += delegate { }; ConnectedToNode += delegate { }; NodeConnectFailed += delegate { }; - ConnectionFailed += delegate { }; Rect += delegate { }; ScreenSize += delegate { }; Renamed += delegate { }; @@ -148,14 +145,13 @@ public class CollabVMClient { /// /// Connect to the CollabVM Server /// - public async Task Connect() { + public async Task Connect() { try { await this.socket.ConnectAsync(this.url, CancellationToken.None); } catch (WebSocketException e) { - this.ConnectionFailed.Invoke(this, e.Message); this.Cleanup(false); - return false; + throw e; } this._connected = true; if (this.username != null) @@ -166,7 +162,7 @@ public class CollabVMClient { this.SendMsg(Guacutils.Encode("connect", this.node)); this.NOPRecieve.Start(); this.WebSocketLoop(); - return true; + return; } private async void WebSocketLoop() {