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;
|
||||
|
||||
public class LiteNetLibServer : LiteNetLibCommunicatorBase, INetworkCommunicatorServer
|
||||
public class LiteNetLibServer : LiteNetLibCommunicatorBase, INetworkCommunicatorServer, IPostUpdate
|
||||
{
|
||||
public string Password { get; private set; } = string.Empty;
|
||||
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 override void EnterUniverse(IUniverse universe)
|
||||
public void PostUpdate()
|
||||
{
|
||||
base.EnterUniverse(universe);
|
||||
universe.OnPostUpdate.AddListener(PollEvents);
|
||||
}
|
||||
|
||||
public override void ExitUniverse(IUniverse universe)
|
||||
{
|
||||
base.ExitUniverse(universe);
|
||||
universe.OnPostUpdate.RemoveListener(PollEvents);
|
||||
Manager.PollEvents();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user