mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-10-26 14:42:49 +00:00
feat: web dashboard and playground work
The NexusDashboard-parity dashboard (dDashboardServer) and everything built on it on the experimental branch: accounts, characters, properties and moderation tools, permissions shared with in-game slash commands, economy reports, World 3D and property 3D views with client scenery, scheduled events (features, vanity changes, live events, announcements, restarts), vanity files and events, the CDClient browser, the message inspector with saved captures, chat filter tools, community challenges, live ops, the AI moderator helper, and the server-side changes they need. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
31
dDashboardServer/routes/Background.h
Normal file
31
dDashboardServer/routes/Background.h
Normal file
@@ -0,0 +1,31 @@
|
||||
#pragma once
|
||||
|
||||
#include <functional>
|
||||
#include <string>
|
||||
|
||||
#include "json.hpp"
|
||||
|
||||
class GameDatabase;
|
||||
|
||||
/**
|
||||
* Runs slow database work (scans over every character, nightly jobs) on a worker thread with its own database
|
||||
* connection, so the dashboard keeps answering while it runs. Tasks must only use the connection they are given:
|
||||
* no Database::Get(), no game data (item names) and no config; do that in the completion, which runs on the main
|
||||
* thread from Update().
|
||||
*/
|
||||
namespace Background {
|
||||
using Task = std::function<nlohmann::json(GameDatabase& db)>;
|
||||
// error is empty on success
|
||||
using Completion = std::function<void(nlohmann::json result, const std::string& error)>;
|
||||
|
||||
void Initialize();
|
||||
void Shutdown();
|
||||
|
||||
// Main loop: run completions of finished tasks
|
||||
void Update();
|
||||
|
||||
// Queue a task. `name` identifies work that should not run twice at once; returns false if it is already queued or running.
|
||||
bool Run(const std::string& name, Task task, Completion done);
|
||||
|
||||
bool IsRunning(const std::string& name);
|
||||
}
|
||||
Reference in New Issue
Block a user