Table of Contents

Class WorldTimeController

Namespace
FishMMO.ControlPanel.Controllers
Assembly
FishMMO-ControlPanel.dll

The world clock: read it, set it, shift it, change its pace, hold and resume it.

[ApiController]
[Route("api/world-time")]
public sealed class WorldTimeController : ControllerBase
Inheritance
WorldTimeController
Inherited Members

Remarks

Every control here writes ONE database row (world_clock_control), and every scene server adopts it on its next pulse, a couple of seconds later, and jumps its players' clocks to it. Nothing here reaches into a process — so every acknowledgement says what was written, never that the world has changed. If no scene server is running, the row is read by nobody.

All clock arithmetic happens in the database. The world time a write replaces, the anchor it writes and the instant it stamps come from one reading of the database clock inside the statement (see WorldClockControlService), so this host's clock skew cannot move the world. This controller only parses and formats: a world timestamp is the row's epoch plus world milliseconds, written Format; a change is +1h30m, -90s, +2d3h4m5.25s. Both forms are parsed by WorldClockText, the same code available to the in-game /admin time commands, so the two surfaces agree about what a typed value means.

The row is created by the first scene server to start, which knows the calendar's epoch. Until then there is nothing to write and the page says so; every write answers 404 with the service's sentence.

Writes sit at Operator plus step-up, as server control does: the in-game commands are Admin, and two faces of one capability that disagree about who may use it make the weaker one the way around the stronger.

Constructors

WorldTimeController(IWorldClockControlService, AuditScope, ILogger<WorldTimeController>)

public WorldTimeController(IWorldClockControlService clock, AuditScope audit, ILogger<WorldTimeController> log)

Parameters

clock IWorldClockControlService
audit AuditScope
log ILogger<WorldTimeController>

Methods

Hold(ReasonRequest)

Holds world time where it stands.

[HttpPost("hold")]
[Authorize(Policy = "Operator.StepUp")]
[Audited("world-time.hold", TargetType = "world-clock")]
public Task<IActionResult> Hold(WorldTimeController.ReasonRequest request)

Parameters

request WorldTimeController.ReasonRequest

Returns

Task<IActionResult>

Read()

The clock as the database reads it now.

[HttpGet]
[Authorize(Policy = "Operator")]
public Task<IActionResult> Read()

Returns

Task<IActionResult>

Remarks

Carries world-now as the database computed it plus the pace, so the browser can tick the display forward from the moment the reply arrived without consulting its own wall clock.

Resume(ReasonRequest)

Resumes at the resume pace from where world time stands.

[HttpPost("resume")]
[Authorize(Policy = "Operator.StepUp")]
[Audited("world-time.resume", TargetType = "world-clock")]
public Task<IActionResult> Resume(WorldTimeController.ReasonRequest request)

Parameters

request WorldTimeController.ReasonRequest

Returns

Task<IActionResult>

Set(SetRequest)

Sets world time to a world timestamp, keeping the pace. A value starting with + or - is a change instead, and is recorded as a shift.

[HttpPost("set")]
[Authorize(Policy = "Operator.StepUp")]
[Audited("world-time.set", TargetType = "world-clock")]
public Task<IActionResult> Set(WorldTimeController.SetRequest request)

Parameters

request WorldTimeController.SetRequest

Returns

Task<IActionResult>

SetPace(PaceRequest)

Changes the pace from this instant, without moving world time.

[HttpPost("pace")]
[Authorize(Policy = "Operator.StepUp")]
[Audited("world-time.pace", TargetType = "world-clock")]
public Task<IActionResult> SetPace(WorldTimeController.PaceRequest request)

Parameters

request WorldTimeController.PaceRequest

Returns

Task<IActionResult>

Shift(ShiftRequest)

Moves world time by a signed change, keeping the pace.

[HttpPost("shift")]
[Authorize(Policy = "Operator.StepUp")]
[Audited("world-time.shift", TargetType = "world-clock")]
public Task<IActionResult> Shift(WorldTimeController.ShiftRequest request)

Parameters

request WorldTimeController.ShiftRequest

Returns

Task<IActionResult>