private async void StartListening() { try { string publicAddress = await IPAddressHelper.GetPublicIPAsync(); string privateAddress = await IPAddressHelper.GetPrivateIPAsync(); if (string.IsNullOrEmpty(publicAddress) || string.IsNullOrEmpty(privateAddress)) { Core.Logger.Log("Network is not available.", "Warning"); Dispose(); } else { if (Core.Settings.Server.GameModes.OfflineMode) { Core.Logger.Log("Players with offline profile can join the server."); } Thread.Add(() => { IsActive = true; do { try { TcpClient client = Listener.AcceptTcpClient(); ThreadPool.QueueWorkItem(() => { if (client != null) { Core.TcpClientCollection.Add(client); } }); } catch (ThreadAbortException) { return; } catch (Exception) { } } while (IsActive); }); if (CheckPortOpen(publicAddress)) { Core.Logger.Log($"Server started. Players can join using the following address: {publicAddress}:{Core.Settings.Server.Port.ToString()} (Global), {privateAddress}:{Core.Settings.Server.Port.ToString()} (Local) and with the following GameMode: {Core.Settings.Server.GameModes.ToString()}."); if (Core.Settings.Server.CheckPort) { StartPortCheck(publicAddress); } } else { Core.Logger.Log($"The specific port {Core.Settings.Server.Port.ToString()} is not opened. External/Global IP will not accept new players."); Core.Logger.Log($"Server started. Players can join using the following address: {privateAddress}:{Core.Settings.Server.Port.ToString()} (Local) and with the following GameMode: {Core.Settings.Server.GameModes.ToString()}."); } } } catch (Exception) { Dispose(); } }