refactor: fixed LiteNetLibServer using events to subscribe to PostUpdate instead of the interface
This commit is contained in:
@@ -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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user