refactor: Folder and Namespace Restructure of Network Code

This commit is contained in:
2024-02-09 10:00:36 +03:00
parent 6c326b1fc6
commit 86ef57fb62
13 changed files with 29 additions and 20 deletions

View File

@@ -0,0 +1,15 @@
using Syntriax.Engine.Core.Abstract;
namespace Syntriax.Engine.Network.Abstract;
public interface INetworkBehaviour : IBehaviour
{
int NetworkId { get; }
bool LocalAssigned { get; }
bool IsServer { get; }
bool IsClient { get; }
INetworkCommunicator NetworkCommunicator { get; }
}

View File

@@ -0,0 +1,6 @@
namespace Syntriax.Engine.Network.Abstract;
public interface INetworkClient : INetworkCommunicator
{
void Connect(string address, int port, string? password = null);
}

View File

@@ -0,0 +1,21 @@
using System;
using LiteNetLib;
using LiteNetLib.Utils;
using Syntriax.Engine.Core.Abstract;
namespace Syntriax.Engine.Network.Abstract;
public interface INetworkCommunicator
{
EventBasedNetListener Listener { get; }
NetManager Manager { get; }
void PollEvents();
void Stop();
void RegisterEntityListener(IEntity entity, Action<NetPacketReader> onDataReceived);
void UnregisterEntityListener(IEntity entity);
NetDataWriter GetEntityWriter(IEntity entity);
}

View File

@@ -0,0 +1,10 @@
namespace Syntriax.Engine.Network.Abstract;
public interface INetworkServer : INetworkCommunicator
{
string Password { get; }
int MaxConnectionCount { get; }
int Port { get; }
void Start(int port, int maxConnectionCount, string? password = null);
}