Engine-Pong/Shared/Network/Abstract/INetworkCommunicator.cs

29 lines
863 B
C#

namespace Syntriax.Engine.Network;
public interface INetworkCommunicator
{
event OnPacketReceivedDelegate? OnPacketReceived;
INetworkCommunicator Stop();
delegate void OnPacketReceivedDelegate(INetworkCommunicator sender, object packet, string from);
}
public interface INetworkCommunicatorClient : INetworkCommunicator
{
INetworkCommunicatorClient Connect(string address, int port, string? password = null);
INetworkCommunicatorClient SendToServer<T>(T packet) where T : class, new();
}
public interface INetworkCommunicatorServer : INetworkCommunicator
{
string Password { get; }
int MaxConnectionCount { get; }
int Port { get; }
INetworkCommunicatorServer Start(int port, int maxConnectionCount, string? password = null);
INetworkCommunicatorServer SendToClient<T>(string to, T packet) where T : class, new();
}