44 lines
1.6 KiB
C#
44 lines
1.6 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
|
|
|
|
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 );
|
|
}
|
|
}
|
|
|
|
}
|