refactor: client is now running on a different thread

This commit is contained in:
2025-05-24 17:08:58 +03:00
parent ed6f783180
commit 0f0180d435
4 changed files with 39 additions and 11 deletions

View File

@@ -3,6 +3,8 @@ using System.Linq;
using LiteNetLib;
using LiteNetLib.Utils;
using Syntriax.Engine.Core;
namespace Syntriax.Engine.Network;
public class LiteNetLibServer : LiteNetLibCommunicatorBase, INetworkCommunicatorServer
@@ -42,7 +44,6 @@ public class LiteNetLibServer : LiteNetLibCommunicatorBase, INetworkCommunicator
return this;
}
public INetworkCommunicatorServer SendToClient<T>(string to, T packet) where T : class, new()
{
bool isBroadcastToAll = to.CompareTo("*") == 0;
@@ -58,4 +59,8 @@ public class LiteNetLibServer : LiteNetLibCommunicatorBase, INetworkCommunicator
return this;
}
protected override void OnEnteredUniverse(IUniverse universe) => universe.OnPostUpdate += PollEvents;
protected override void OnExitedUniverse(IUniverse universe) => universe.OnPostUpdate -= PollEvents;
private void PollEvents(IUniverse sender, UniverseTime engineTime) => Manager.PollEvents();
}