From a2057e1b500a133c3e23a56c181c348a14916a77 Mon Sep 17 00:00:00 2001 From: Stone_Red <56473591+Stone-Red-Code@users.noreply.github.com> Date: Thu, 14 Dec 2023 22:21:07 +0100 Subject: [PATCH] Add more debug logs --- .../Networking/NetworkClient.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/HyperbolicDownloaderApi/Networking/NetworkClient.cs b/HyperbolicDownloaderApi/Networking/NetworkClient.cs index 224c5a1..cf01beb 100644 --- a/HyperbolicDownloaderApi/Networking/NetworkClient.cs +++ b/HyperbolicDownloaderApi/Networking/NetworkClient.cs @@ -113,19 +113,27 @@ internal class NetworkClient(FilesManager filesManager) if (dataReceived.StartsWith("Download")) { + ApiManager.SendNotificationMessageNewLine($"{(client.Client.RemoteEndPoint as IPEndPoint)?.Address} > Download request", NotificationMessageType.Debug); _ = Upload(client, dataReceived[8..]); continue; } if (string.IsNullOrWhiteSpace(dataReceived)) { + ApiManager.SendNotificationMessageNewLine($"{(client.Client.RemoteEndPoint as IPEndPoint)?.Address} > Disconnected", NotificationMessageType.Debug); client.Close(); continue; } + ApiManager.SendNotificationMessageNewLine($"{(client.Client.RemoteEndPoint as IPEndPoint)?.Address} > Deserializing data", NotificationMessageType.Debug); + DataContainer? dataContainer = JsonSerializer.Deserialize(dataReceived); + ApiManager.SendNotificationMessageNewLine($"{(client.Client.RemoteEndPoint as IPEndPoint)?.Address} > Data deserialized", NotificationMessageType.Debug); + if (dataContainer is not null && events.TryGetValue(dataContainer.EventName, out (Type type, Delegate method) value)) { + ApiManager.SendNotificationMessageNewLine($"{(client.Client.RemoteEndPoint as IPEndPoint)?.Address} > Found event", NotificationMessageType.Debug); + (Type type, Delegate method) = value; Type eventArgsType = typeof(MessageRecivedEventArgs<>).MakeGenericType(type); @@ -138,6 +146,12 @@ internal class NetworkClient(FilesManager filesManager) _ = (method?.DynamicInvoke(this, eventArgs)); } + else + { + ApiManager.SendNotificationMessageNewLine($"{(client.Client.RemoteEndPoint as IPEndPoint)?.Address} > Event not found", NotificationMessageType.Debug); + } + + ApiManager.SendNotificationMessageNewLine($"{(client.Client.RemoteEndPoint as IPEndPoint)?.Address} > Closing connection", NotificationMessageType.Debug); client.Close();