Rework server to be non static

This commit is contained in:
derek.holloway committed 2026-07-08 13:13:23 -07:00
1 parent 875a5ae3e9
commit 6f910e969a
6 files changed
+97 -79

No files matched your search

+43
View File
@@ -0,0 +1,43 @@
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
ServerListener Listener { get; set;}
public ConcurrentDictionary<string, ServerConnection> Connections;
public ServerEntity(IPEndPoint ListenerAddress) {
Listener = new ServerListener(ListenerAddress, this);
Connections = new ConcurrentDictionary<string, ServerConnection>();
}
// Functions
public event Action<ServerConnection> onUserConnected;
public void InvokeUserConnected( ServerConnection user ){
onUserConnected?.Invoke( user );
}
public event Action<dynamic> onDataReceived;
public void InvokeDataReceived( dynamic data ){
onDataReceived?.Invoke( data );
}
public event Action<ServerConnection> onUserDisconnected;
public void InvokeUserDisconnected( ServerConnection user ){
onUserDisconnected?.Invoke( user );
}
}
}