mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-10-11 23:33:50 +00:00
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>
51 lines
2.1 KiB
C++
51 lines
2.1 KiB
C++
#pragma once
|
|
|
|
#include <optional>
|
|
|
|
#include <chrono>
|
|
#include <cstdint>
|
|
#include <functional>
|
|
#include <string>
|
|
|
|
#include "json.hpp"
|
|
#include "PlayerAction.h"
|
|
|
|
/**
|
|
* Sends player actions (kick, refresh, rescue) through master to every world server and reports the outcome.
|
|
*
|
|
* Results arrive asynchronously, so HTTP handlers return a request id immediately. When the result comes in,
|
|
* the completion callback runs on the main thread, the outcome is pushed on the `action_result` WebSocket
|
|
* topic to the owner's connections only, and it can be polled with GET /api/actions/:id.
|
|
*/
|
|
namespace PlayerActions {
|
|
struct Outcome {
|
|
bool success{true};
|
|
std::string message{};
|
|
// Only returned by GetStatus to the account that started the work, never broadcast
|
|
nlohmann::json data = nullptr;
|
|
// For work started with Begin: how many players or characters it changed. Left out of the result when unset,
|
|
// rather than claiming 0 (player actions report what the worlds answered)
|
|
std::optional<uint32_t> affected{};
|
|
};
|
|
|
|
// Called with the aggregated result; returns the message shown to the moderator
|
|
using Completion = std::function<Outcome(const PlayerActionResult& result)>;
|
|
|
|
// Send an action to all worlds. Returns the request id. Only ownerAccountId (who asked for it) gets the outcome.
|
|
uint32_t Request(PlayerActionRequest request, uint32_t ownerAccountId, Completion onComplete);
|
|
|
|
// Feed a PLAYER_ACTION_RESULT packet from master
|
|
void HandleResult(const PlayerActionResult& result);
|
|
|
|
// Expire requests master never answered. Call once per tick.
|
|
void Update();
|
|
|
|
// Track some other asynchronous work (e.g. sending an email) with the same result reporting.
|
|
// Begin returns a request id; Finish publishes the outcome like a player action result.
|
|
uint32_t Begin(uint32_t ownerAccountId, std::chrono::seconds timeout = std::chrono::minutes(2));
|
|
void Finish(uint32_t requestId, const Outcome& outcome);
|
|
|
|
// Result of a finished request, or {"status": "pending"} / {"status": "unknown"}. Only the owner sees it; anyone else gets "unknown".
|
|
nlohmann::json GetStatus(uint32_t requestId, uint32_t requesterAccountId);
|
|
}
|