Table of Contents

Class WorldQueuePlaceMemory

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

Places in the open-world queue held for accounts whose wait ended without their say, so that coming back within a grace window resumes the place instead of starting at the back.

public sealed class WorldQueuePlaceMemory
Inheritance
WorldQueuePlaceMemory
Inherited Members

Remarks

The open-world queue is first in, first out by when each connection began waiting (SelectForRouting<T>(List<QueueCandidate<T>>, int, List<T>)). That order belonged to the connection, so anything that ended the connection ended the place: a dropped link that reconnected four seconds later, or a player the server sent back because the line had stalled, rejoined behind everyone who arrived after them. On a full world a flaky link meant never reaching the front.

A place is remembered per account, for one scene, with the time the account began waiting. Rejoining that scene's queue within GraceSeconds resumes it; rejoining any other scene, or after the window, starts fresh. A resumed place is spent: the same wait can be remembered again if it ends again, but it cannot be claimed twice. A player who chose to leave the queue is Forget(string)-ed and loses it.

Every time is a MonotonicClock reading. Main thread only; no Unity or network dependency, so the rules are pinned by tests.

Properties

Count

How many places are held.

public int Count { get; }

Property Value

int

GraceSeconds

How long a place is held after the wait ended. Zero or less holds nothing.

public double GraceSeconds { get; set; }

Property Value

double

Methods

Clear()

Forgets every place.

public void Clear()

Forget(string)

Gives up whatever place an account holds. For a player who chose to leave, and for one who has been placed.

public void Forget(string accountName)

Parameters

accountName string

IsHeld(Place, string, double, double)

Whether a remembered place can be resumed by a join of sceneName's queue at now: the same queue, within the grace window.

public static bool IsHeld(WorldQueuePlaceMemory.Place place, string sceneName, double now, double graceSeconds)

Parameters

place WorldQueuePlaceMemory.Place
sceneName string
now double
graceSeconds double

Returns

bool

Remarks

The scene name is compared ordinally, as the waiting queues key their scenes.

Remember(string, string, double, double)

Remembers where an account stood when its wait ended without its say.

public void Remember(string accountName, string sceneName, double waitingSince, double now)

Parameters

accountName string

The account.

sceneName string

The open-world scene it was waiting for.

waitingSince double

When it began waiting.

now double

The current monotonic reading.

Remarks

A place already held for the same scene keeps the earlier of the two starts: an account that had two connections in the line (a reconnect that arrived before the old one was noticed gone) is owed the older place, whichever connection ends last.

Sweep(double)

Drops every place whose grace window has closed.

public int Sweep(double now)

Parameters

now double

The current monotonic reading.

Returns

int

How many were dropped.

TryResume(string, string, double, out double)

Takes back the place an account left in a scene's queue, if it is still held.

public bool TryResume(string accountName, string sceneName, double now, out double waitingSince)

Parameters

accountName string

The account joining the queue.

sceneName string

The open-world scene whose queue it is joining.

now double

The current monotonic reading.

waitingSince double

When the account originally began waiting, when resumed.

Returns

bool

True when the place was resumed.

Remarks

Whatever is held for the account is dropped either way. Joining a different scene's queue ends the old wait, and an expired place was never going to be claimed.