refactor: fixed LiteNetLibServer using events to subscribe to PostUpdate instead of the interface

This commit is contained in:
2026-01-29 22:29:19 +03:00
parent b9f3227f73
commit c355c666e0

View File

@@ -6,7 +6,7 @@ using Engine.Core.Debug;
namespace Engine.Systems.Network; namespace Engine.Systems.Network;
public class LiteNetLibServer : LiteNetLibCommunicatorBase, INetworkCommunicatorServer public class LiteNetLibServer : LiteNetLibCommunicatorBase, INetworkCommunicatorServer, IPostUpdate
{ {
public string Password { get; private set; } = string.Empty; public string Password { get; private set; } = string.Empty;
public int MaxConnectionCount { get; private set; } = 2; public int MaxConnectionCount { get; private set; } = 2;
@@ -104,17 +104,8 @@ public class LiteNetLibServer : LiteNetLibCommunicatorBase, INetworkCommunicator
} }
} }
private void PollEvents(IUniverse sender, IUniverse.UpdateArguments args) => Manager.PollEvents(); public void PostUpdate()
public override void EnterUniverse(IUniverse universe)
{ {
base.EnterUniverse(universe); Manager.PollEvents();
universe.OnPostUpdate.AddListener(PollEvents);
}
public override void ExitUniverse(IUniverse universe)
{
base.ExitUniverse(universe);
universe.OnPostUpdate.RemoveListener(PollEvents);
} }
} }