mirror of
https://github.com/Stone-Red-Code/HyperbolicDownloader.git
synced 2026-09-06 23:40:40 +02:00
Add debug logs
This commit is contained in:
@@ -92,14 +92,25 @@ internal class NetworkClient(FilesManager filesManager)
|
||||
{
|
||||
try
|
||||
{
|
||||
ApiManager.SendNotificationMessageNewLine("Listening for connections...", NotificationMessageType.Debug);
|
||||
|
||||
TcpClient client = tcpListener.AcceptTcpClient();
|
||||
|
||||
ApiManager.SendNotificationMessageNewLine($"{(client.Client.RemoteEndPoint as IPEndPoint)?.Address} > Connected", NotificationMessageType.Debug);
|
||||
|
||||
NetworkStream nwStream = client.GetStream();
|
||||
byte[] buffer = new byte[client.ReceiveBufferSize];
|
||||
|
||||
ApiManager.SendNotificationMessageNewLine($"{(client.Client.RemoteEndPoint as IPEndPoint)?.Address} > Reading data", NotificationMessageType.Debug);
|
||||
|
||||
int bytesRead = await nwStream.ReadAsync(buffer.AsMemory(0, client.ReceiveBufferSize));
|
||||
|
||||
ApiManager.SendNotificationMessageNewLine($"{(client.Client.RemoteEndPoint as IPEndPoint)?.Address} > Data read", NotificationMessageType.Debug);
|
||||
|
||||
string dataReceived = Encoding.ASCII.GetString(buffer, 0, bytesRead);
|
||||
|
||||
ApiManager.SendNotificationMessageNewLine($"{(client.Client.RemoteEndPoint as IPEndPoint)?.Address} > Data: {dataReceived}", NotificationMessageType.Debug);
|
||||
|
||||
if (dataReceived.StartsWith("Download"))
|
||||
{
|
||||
_ = Upload(client, dataReceived[8..]);
|
||||
@@ -129,13 +140,12 @@ internal class NetworkClient(FilesManager filesManager)
|
||||
}
|
||||
|
||||
client.Close();
|
||||
|
||||
ApiManager.SendNotificationMessageNewLine($"{(client.Client.RemoteEndPoint as IPEndPoint)?.Address} > Disconnected", NotificationMessageType.Debug);
|
||||
}
|
||||
catch (SocketException ex)
|
||||
{
|
||||
if (ex.SocketErrorCode != SocketError.Interrupted)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
ApiManager.SendNotificationMessageNewLine(ex.Message, NotificationMessageType.Log);
|
||||
}
|
||||
}
|
||||
tcpListener.Stop();
|
||||
|
||||
Reference in New Issue
Block a user