public void Initialize() { _timer = new System.Timers.Timer(RecentIPsUpdateRate.TotalMilliseconds); _timer.Elapsed += OnTimerIntervalElapsed; _recent_server_creators_IPs = new Queue <TimestampedIP>(); _tcp_listener = new TcpListener(Socket); DbServer = new DatabaseServer(); AuthServer = new AuthenticationServer.AuthenticationServer(_tcp_listener, DbServer); DbServer.Initialize(); _registered_servers = DbServer.SelectActiveGameServers(); AuthServer.Initialize(); _thread_mre = new ManualResetEvent(false); _main_mre = new ManualResetEvent(false); _network_handling_thread = new Thread(ServerLoop); _network_handling_thread.IsBackground = false; Status = ServerStatus.Initialized; OnInitialization?.Invoke(this, null); }
public void Dispose() { //_main_mre.WaitOne(); Stop(); _timer.Dispose(); _registered_servers = null; _recent_server_creators_IPs = null; AuthServer.Dispose(); AuthServer = null; DbServer.Dispose(); DbServer = null; Socket = null; Status = ServerStatus.Uninitialized; OnTermination?.Invoke(this, null); }