just throw the damn exception instead of weird event shit (why did I do that)

This commit is contained in:
Elijahr2411 2023-08-28 20:50:05 -04:00
parent fd09840a1c
commit 0907d7b395

View file

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