/// <summary> /// Boots up the server /// </summary> public static void Start() { Config.Load(); Listener = new TcpIPListener(Config.Port); Listener.OnSocketConnect += ProcessConnection; Listener.Start(); GenerateSalt(); Scheduler = new Scheduler("Main.Scheduler"); Scheduler.Start(); Players = new List <Player>(); Levels = new List <Level>(); Group.Initialise(); Command.Initialise(); Seed.Initialise(); EntityHandler.Initialise(); PlayerDB = new SqlDatabase("PlayerDB"); MainLevel = NbtLoader.Load(Config.MainLevel) ?? new Level("main", 64, 64, 64); Levels.Add(MainLevel); Heartbeat.Beat(); }
public static void Initialize(bool isDebugger, bool isConnected, bool doHeartBeat, int HeartBeatDelay = 80) { //USE_PROTECTION_LIB Protection protect = new Protection(); if (isDebugger) { if (protect.isDebugged()) { User.Guard.Admin.BlackList(); endClient("Tampering Detected"); } } if (isConnected) { if (!protect.isConnected()) { endClient(); } } if (doHeartBeat) { Heartbeat hb = new Heartbeat(HeartBeatDelay); hb.Beat(); } }
// 程式心跳 private void HeartbeatTimer_Tick(object sender, EventArgs e) { if (DateTime.Now.Millisecond < 100) { return; } Clock.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); Clock.BackColor = Colors[(new Random(Guid.NewGuid().GetHashCode())).Next(Colors.Length)]; Application.DoEvents(); // 寫 MonitorFile (1次/1分鐘),且「開始」按鈕為不可按的狀態才寫。 if (DateTime.Now.Second == 0 && StartButton.Enabled == false) { Heartbeat.Beat(); } // 每天 00:00:00 刪除一個月前的記錄檔 if (DateTime.Now.ToString("HHmmss") == "000000") { Task.Run(() => { Optimizer.OptimizeEnvironment(); }); } }
public void OnKeepHealth() { Heartbeat.Beat(); }