Table of Contents

Class WorldClockHost

Namespace
FishMMO.Server.Implementation.World.SceneServer.Clock
Assembly
FishMMO.Server.dll

Keeps this scene server's WorldClock anchored to the database server's clock and tells clients the anchor.

public sealed class WorldClockHost
Inheritance
WorldClockHost
Inherited Members

Remarks

The database clock is the single reference: every scene server already talks to it, so they all agree even when their own host clocks are wrong. The host clock is only used to anchor immediately at startup (marked unverified) and to measure the query's round trip.

The world clock control. An admin may set the world's time to the millisecond, hold it or race it (/admin time, the Control Panel). That is one database row, world_clock_control: world time = base + rate × (database clock − reference). It is read with the database clock in one round trip every ControlPollSeconds; a new revision is adopted at once (Override(uint, double, double, bool)) at the tick it is read on, and broadcast, so every scene server and client jumps to it within a poll. Between revisions only the clock's own drift is corrected, eased in over ten seconds as before.

Without the table (the migration not yet applied) it runs as it always did: world time is the database clock less the epoch, at real time.

Constructors

WorldClockHost(NetworkManager, IDatabase, long, Func<Task<bool>>)

public WorldClockHost(NetworkManager networkManager, IDatabase database, long epochUnixSeconds, Func<Task<bool>> seedControl = null)

Parameters

networkManager NetworkManager
database IDatabase
epochUnixSeconds long
seedControl Func<Task<bool>>

Writes the control row if there is none (the world clock service), true when one exists after.

Fields

ControlPollSeconds

How often the control row is read, s: how soon an admin's change reaches this server.

public const float ControlPollSeconds = 2

Field Value

float

UnverifiedIntervalSeconds

public const float UnverifiedIntervalSeconds = 30

Field Value

float

VerifiedIntervalSeconds

public const float VerifiedIntervalSeconds = 600

Field Value

float

Properties

AdoptedRevision

The revision of the control row this server runs on; long.MinValue before one is read.

public long AdoptedRevision { get; }

Property Value

long

SecondsUntilCheck

Seconds until the next database check. Diagnostics only.

public float SecondsUntilCheck { get; }

Property Value

float

Methods

CheckNow()

Reads the control row at the next update, instead of at the next poll: after an admin on this server wrote it.

public void CheckNow()

SendTo(NetworkConnection)

Sends the current anchor to one client, on arrival.

public void SendTo(NetworkConnection connection)

Parameters

connection NetworkConnection

Start()

public void Start()

Stop()

public void Stop()

Tick(float)

public void Tick(float deltaTime)

Parameters

deltaTime float