chore: added debug entry for logs

This commit is contained in:
2026-04-14 10:07:51 +03:00
parent 7e7b910dd3
commit 3295701664
5 changed files with 21 additions and 30 deletions

View File

@@ -8,7 +8,7 @@ using Engine.Core.Debug;
namespace Engine.Systems.Network;
public class LiteNetLibClient : LiteNetLibCommunicatorBase, INetworkCommunicatorClient
public class LiteNetLibClient : LiteNetLibCommunicatorBase, INetworkCommunicatorClient, IEnterUniverse
{
private readonly NetDataWriter netDataWriter = new();
private readonly NetDataWriter netDataWriterEncrypted = new();
@@ -31,8 +31,8 @@ public class LiteNetLibClient : LiteNetLibCommunicatorBase, INetworkCommunicator
System.Net.IPAddress[] addresses = System.Net.Dns.GetHostAddresses(address);
string connectionAddress = addresses.FirstOrDefault(a => a.AddressFamily == AddressFamily.InterNetwork, addresses[0]).ToString();
logger?.Log(this, $"Connecting to server at '{address}:{port}' with password '{password}'");
logger?.Log(this, $"Resolved address for {address}: {connectionAddress}");
ILogger.Shared.LogInfo(this, $"Connecting to server at '{address}:{port}' with password '{password}'");
ILogger.Shared.LogInfo(this, $"Resolved address for {address}: {connectionAddress}");
Manager.Start();
Manager.Connect(connectionAddress, port, password);
@@ -70,10 +70,8 @@ public class LiteNetLibClient : LiteNetLibCommunicatorBase, INetworkCommunicator
return this;
}
public override void EnterUniverse(IUniverse universe)
public void EnterUniverse(IUniverse universe)
{
base.EnterUniverse(universe);
cancellationTokenSource = new CancellationTokenSource();
PollEvents(cancellationTokenSource.Token);
}
@@ -94,7 +92,7 @@ public class LiteNetLibClient : LiteNetLibCommunicatorBase, INetworkCommunicator
{
Thread.Sleep(1);
try { Manager.PollEvents(); }
catch (Exception e) { logger?.LogException(this, e, force: true); }
catch (Exception e) { ILogger.Shared.LogException(this, e, force: true); }
}
}, cancellationToken);
}