feat: added revised version of the old networking system
This commit is contained in:
8
Shared/Network/Abstract/INetworkBehaviour.cs
Normal file
8
Shared/Network/Abstract/INetworkBehaviour.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
using Syntriax.Engine.Core;
|
||||
|
||||
namespace Syntriax.Engine.Network;
|
||||
|
||||
public interface INetworkBehaviour : IBehaviour, INetworkEntity
|
||||
{
|
||||
INetworkCommunicator NetworkCommunicator { get; }
|
||||
}
|
28
Shared/Network/Abstract/INetworkCommunicator.cs
Normal file
28
Shared/Network/Abstract/INetworkCommunicator.cs
Normal 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);
|
||||
}
|
8
Shared/Network/Abstract/INetworkEntity.cs
Normal file
8
Shared/Network/Abstract/INetworkEntity.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
using Syntriax.Engine.Core;
|
||||
|
||||
namespace Syntriax.Engine.Network;
|
||||
|
||||
public interface INetworkEntity : IEntity
|
||||
{
|
||||
void ReceiveData(object data);
|
||||
}
|
12
Shared/Network/Abstract/INetworkManager.cs
Normal file
12
Shared/Network/Abstract/INetworkManager.cs
Normal 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; }
|
||||
}
|
3
Shared/Network/Abstract/INetworkPacket.cs
Normal file
3
Shared/Network/Abstract/INetworkPacket.cs
Normal file
@@ -0,0 +1,3 @@
|
||||
namespace Syntriax.Engine.Network;
|
||||
|
||||
public interface INetworkPacket;
|
7
Shared/Network/Abstract/PacketEntityData.cs
Normal file
7
Shared/Network/Abstract/PacketEntityData.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace Syntriax.Engine.Network;
|
||||
|
||||
public interface INetworkPacketEntityData<T> : INetworkPacket
|
||||
{
|
||||
string Entity { get; }
|
||||
T Data { get; }
|
||||
}
|
Reference in New Issue
Block a user