public static void Init(string configFile) { Instance = new CenterServer() { ConfigName = configFile }; Instance.Load(); }
private void InitializeServer() { try { CenterServer.Init(Program.IMGFilename); Invoke((MethodInvoker) delegate { Text += " (" + Program.IMGFilename + ")"; if (CenterServer.Tespia) { Text += " -TESPIA MODE-"; #if DEBUG Text += " -DEBUG-"; #endif Icon = Resources.Tespia; ShowIcon = true; } }); MasterThread.RepeatingAction.Start( "Server List Updator", date => { try { BeginInvoke((MethodInvoker) delegate { UpdateServerList(); txtPingEntries.Text = Pinger.CurrentLoggingConnections.ToString(); }); } catch { } }, 0, 1000 ); // Update the online player count every minute MasterThread.RepeatingAction.Start( "OnlinePlayerCounter", date => { int totalCount = 0; foreach (var kvp in CenterServer.Instance.LocalServers) { var ls = kvp.Value; if (ls.Connected == false) { continue; } if (ls.Type != LocalServerType.Login && ls.Type != LocalServerType.Game && ls.Type != LocalServerType.Shop) { continue; } totalCount += ls.Connections; _onlinePlayerLog.Info(new OnlinePlayerCount { count = ls.Connections, serverName = ls.Name }); } _onlinePlayerLog.Info(new OnlinePlayerCount { count = totalCount, serverName = "TotalCount-" + CenterServer.Instance.World.ID }); }, 60000, 60000 ); Pinger.Init(Program.MainForm.LogAppend, Program.MainForm.LogAppend); } catch (Exception ex) { Program.LogFile.WriteLine("Got exception @ frmMain::InitServer : {0}", ex.ToString()); MessageBox.Show($"[{DateTime.Now}][CENTER SERVER] Got exception @ frmMain::InitServer : {ex}"); Environment.Exit(5); } }