30 lines
916 B
C#
30 lines
916 B
C#
using Syntriax.Engine.Core;
|
|
|
|
namespace Syntriax.Engine.Network;
|
|
|
|
public interface INetworkCommunicator
|
|
{
|
|
INetworkCommunicator Stop();
|
|
|
|
INetworkCommunicator SubscribeToPackets<T>(Event<string, T>.EventHandler callback);
|
|
INetworkCommunicator UnsubscribeFromPackets<T>(Event<string, T>.EventHandler callback);
|
|
}
|
|
|
|
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();
|
|
}
|