using System; using System.Collections.Concurrent; using System.Net; namespace Mistox.Server { public class ServerEntity { // Class Definitions public string ServerName { get; set; } = ""; // The name of the server public int MaxClients { get; set; } = 10; // The max players per server public float ConnectionRange { get; set; } = 40; // InGame distance for valid conections public int ConnectionTimeoutSeconds { get; set; } = 10; // If no reply in time kill the connection public bool Alive { get; set; } = true; // Is the server running public ConcurrentDictionary Connections; // All the active connections. key is username private readonly ServerListener Listener; // The Connection Listener singleton public ServerEntity(IPEndPoint ListenerAddress) { Listener = new ServerListener(ListenerAddress, this); Connections = new ConcurrentDictionary(); } // Functions public event Action onUserConnected; public void InvokeUserConnected( ServerConnection user ){ onUserConnected?.Invoke( user ); } public event Action onDataReceived; public void InvokeDataReceived( dynamic data ){ onDataReceived?.Invoke( data ); } public event Action onUserDisconnected; public void InvokeUserDisconnected( ServerConnection user ){ onUserDisconnected?.Invoke( user ); } } }