コード例 #1
0
ファイル: Hypercube.cs プロジェクト: umby24/Hypercube
        /// <summary>
        /// Stops the server and prepares it to be started again.
        /// </summary>
        public static void Stop()
        {
            OnlinePlayers = 0;

            TaskScheduler.TaskThread.Abort();
            TaskScheduler.ScheduledTasks.Clear();

            Hb = null;

            Nh.Stop();

            Setting.SaveAll();

            foreach (var m in Maps.Values)
                m.Shutdown();

            _actionThread.Abort();

            DB.DBConnection.Close();
        }
コード例 #2
0
ファイル: Hypercube.cs プロジェクト: umby24/Hypercube
        /// <summary>
        /// Starts the server.
        /// </summary>
        public static void Start()
        {
            Uptime = DateTime.UtcNow;
            Nh.Start(); // -- Start up the server listening system
            Running = true; // -- Server is now classified as running (keeps all major loops running)

            TaskScheduler.TaskThread = new Thread(TaskScheduler.RunTasks); // -- Create a single thread to run smaller server tasks at registered intervals
            TaskScheduler.TaskThread.Start();

            Hb = new Heartbeat(); // -- Register server tasks
            TaskScheduler.CreateTask("File Reloading", new TimeSpan(0, 0, 1), Setting.SettingsMain);
            TaskScheduler.CreateTask("Lua file reloading", new TimeSpan(0, 0, 1), Luahandler.Main);

            foreach (var m in Maps.Values) {
                TaskScheduler.CreateTask("Memory Conservation (" + m.CWMap.MapName + ")", new TimeSpan(0, 0, 30), m.MapMain);
                TaskScheduler.CreateTask("Autosave (" + m.CWMap.MapName + ")", new TimeSpan(0,m.HCSettings.SaveInterval, 0), m.MapSave);

                m.Teleporters = new TeleporterContainer(m.CWMap.MapName);

                m.BlockThread = new Thread(m.BlockQueueLoop); // -- Block queue and physics queue get their own threads, as they can be very intensive at times.
                m.BlockThread.Start();

                m.PhysicsThread = new Thread(m.PhysicsQueueLoop);
                m.PhysicsThread.Start();
            }
            // -- Create tasks for generating html files, and handling client actions.
            TaskScheduler.CreateTask("Client Actions", new TimeSpan(0, 0, 0, 0, 50), HypercubeMap.HandleActionQueue);
            TaskScheduler.CreateTask("Watchdog", new TimeSpan(0, 0, 30), Watchdog.GenHtml);

            _actionThread = new Thread(ProcessActions); // -- Create a thread to handle map actions (Fills, resizes, deletes).
            _actionThread.Start();

             // -- Server fully started
            Logger.Log("Core", "Server started.", LogType.Info);
        }