feat: added revised version of the old networking system

This commit is contained in:
2025-05-10 22:38:01 +03:00
parent cd3e23b427
commit 23a0c8e893
13 changed files with 291 additions and 3 deletions

View File

@@ -0,0 +1,8 @@
using Syntriax.Engine.Core;
namespace Syntriax.Engine.Network;
public interface INetworkBehaviour : IBehaviour, INetworkEntity
{
INetworkCommunicator NetworkCommunicator { get; }
}

View File

@@ -0,0 +1,28 @@
namespace Syntriax.Engine.Network;
public interface INetworkCommunicator
{
event OnPacketReceivedDelegate? OnPacketReceived;
void Stop();
delegate void OnPacketReceivedDelegate(INetworkCommunicator sender, object packet, string from);
}
public interface INetworkCommunicatorClient : INetworkCommunicator
{
void Connect(string address, int port, string? password = null);
void SendToServer(INetworkPacket packet);
}
public interface INetworkCommunicatorServer : INetworkCommunicator
{
string Password { get; }
int MaxConnectionCount { get; }
int Port { get; }
void Start(int port, int maxConnectionCount, string? password = null);
void SendToClient(string to, INetworkPacket packet);
}

View File

@@ -0,0 +1,8 @@
using Syntriax.Engine.Core;
namespace Syntriax.Engine.Network;
public interface INetworkEntity : IEntity
{
void ReceiveData(object data);
}

View File

@@ -0,0 +1,12 @@
using System.Collections.Generic;
using Syntriax.Engine.Core;
namespace Syntriax.Engine.Network;
public interface INetworkManager
{
INetworkCommunicator NetworkCommunicator { get; }
IReadOnlyDictionary<string, INetworkEntity> NetworkEntities { get; }
IBehaviourCollector<INetworkEntity> NetworkEntityCollector { get; }
}

View File

@@ -0,0 +1,3 @@
namespace Syntriax.Engine.Network;
public interface INetworkPacket;

View File

@@ -0,0 +1,7 @@
namespace Syntriax.Engine.Network;
public interface INetworkPacketEntityData<T> : INetworkPacket
{
string Entity { get; }
T Data { get; }
}