Files
GameServer/MistoxServer/Server/MistoxServer.cs
T
2026-08-03 10:01:31 -07:00

44 lines
1.7 KiB
C#

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<string, ServerConnection> 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<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 );
}
}
}