Table of Contents

Class WorldSceneRoutingRules

Namespace
FishMMO.Server.Implementation.World.WorldServer
Assembly
FishMMO.Server.dll

The decisions the world server's scene routing makes, as pure functions.

public static class WorldSceneRoutingRules
Inheritance
WorldSceneRoutingRules
Inherited Members

Remarks

WorldSceneSystem gathers everything a routing pass needs in a few batched reads, decides with these, then writes and sends in batches. Keeping the decisions here, free of the network and the database, is what lets tests pin them as tables.

Methods

DecideInstanceRoute(RowLookup, SceneStatus, double, RowLookup, bool, double)

Decides where a character bound to an instance goes.

public static WorldSceneRoutingRules.InstanceRoute DecideInstanceRoute(WorldSceneRoutingRules.RowLookup scene, SceneStatus status, double sceneAgeSeconds, WorldSceneRoutingRules.RowLookup sceneServer, bool sceneServerLive, double readyGraceSeconds)

Parameters

scene WorldSceneRoutingRules.RowLookup

What the read of the instance's scene row answered.

status SceneStatus

The row's status, when it was found.

sceneAgeSeconds double

The row's age by the database clock, when it was found.

sceneServer WorldSceneRoutingRules.RowLookup

What the read of the hosting scene server answered. Only consulted for a Ready row.

sceneServerLive bool

Whether that scene server is still pulsing, when it was found.

readyGraceSeconds double

How long a row may stay short of Ready before the character is released.

Returns

WorldSceneRoutingRules.InstanceRoute

Remarks

Only an answer releases a character. A read that failed is not an answer, and treating it as one cleared the instance flag of a character whose instance was alive, or deleted the row of a live, populated instance so every other member was ejected on their next reconnect.

A row that is still loading is bounded by its own age, not by the connection's wait: the queue TTL ends one visit, the client reconnects, and without a bound on the row it is queued behind the same dead instance forever.

NeedsSceneBind(long, long, long, long)

Whether an open-world assignment has to rewrite the character's scene binding before the client is sent on.

public static bool NeedsSceneBind(long characterWorldServerID, long characterSceneHandle, long worldServerID, long assignedHandle)

Parameters

characterWorldServerID long
characterSceneHandle long
worldServerID long
assignedHandle long

Returns

bool

Remarks

The scene server matches an arriving character on the (world server, scene, handle) it reads back from the row, so any of the three being stale gets the client refused.

NeedsWorldBind(long, long)

Whether a character being sent to its instance has to be bound to this world server first.

public static bool NeedsWorldBind(long characterWorldServerID, long worldServerID)

Parameters

characterWorldServerID long
worldServerID long

Returns

bool

Remarks

Only the world server id can be stale here: the instance route does not change the character's scene. An unknown world server id (0) binds nothing.

QueueWaitExpired(double, double?, double, double)

Whether a queued connection's wait has run out.

public static bool QueueWaitExpired(double queuedAt, double? lastPlacementAt, double now, double ttlSeconds)

Parameters

queuedAt double

When the connection joined the queue, in monotonic seconds.

lastPlacementAt double?

When its scene last placed anyone, or null if it never has.

now double

The current monotonic reading.

ttlSeconds double

The TTL for the kind of wait this is.

Returns

bool

True when the connection should be purged.

Remarks

The wait is timed from the later of joining the queue and the scene's last placement. The queue is first in, first out, so while it is placing anyone the players behind are moving forward and keep their place; only a line that has placed nobody for a whole TTL sends its waiters back to choose again. Timed from joining alone, a queue longer than one TTL's worth of placements purged its tail while the line moved, and a retry went to the back, so those players cycled forever.

SelectForRouting<T>(List<QueueCandidate<T>>, int, List<T>)

Picks which waiting connections one open-world routing pass takes off the queue.

public static void SelectForRouting<T>(List<WorldSceneRoutingRules.QueueCandidate<T>> candidates, int freeCapacity, List<T> selected)

Parameters

candidates List<WorldSceneRoutingRules.QueueCandidate<T>>

Everyone waiting on the scene. Reordered in place.

freeCapacity int

Free slots across every routable instance of the scene.

selected List<T>

Receives the picked connections, oldest first.

Type Parameters

T

Remarks

The oldest freeCapacity connections, plus every AlwaysRoute one. A pass cannot place more than the free capacity, so taking the whole queue — which it used to — read a character row for every waiting player and put back everyone it could not place, one queued action each: 2,500 rows and 2,490 re-queues every two seconds to route ten.

Oldest first by the same order the queue positions are reported in (arrival, then client id), so the players told they are at the front are the ones placed first. A set has no order of its own, so the whole-queue pass handed the free slots to whoever happened to enumerate first.