Table of Contents

Class LoginQueueSystem

Namespace
FishMMO.Server.Implementation.LoginServer
Assembly
FishMMO.Server.dll

Manages a FIFO login queue for clients arriving when the server is at authentication capacity. Queued clients stay connected at the QUIC layer and receive periodic position updates via LoginQueuePositionBroadcast. When admitted (position reaches 0), the client re-initiates the handshake and proceeds through normal authentication.

Update rate: The LoginQueueUpdateRateSeconds config key controls how often position updates are broadcast. This is server-authoritative only — clients cannot request faster updates.

Admission rate: Clients are admitted from the queue at a server-configured rate (LoginQueueAdmissionRatePerSecond) to prevent the newly-admitted clients from immediately re-saturating auth capacity.

public class LoginQueueSystem : ServerBehaviour, IServerBehaviour<INetworkManagerWrapper, ServerManager, NetworkConnection, IServerBehaviour>, IServerBehaviour, IServerComponent<INetworkManagerWrapper, ServerManager, NetworkConnection, IServerBehaviour>, IServerComponent
Inheritance
Object
ScriptableObject
LoginQueueSystem
Implements
IServerBehaviour<INetworkManagerWrapper, ServerManager, NetworkConnection, IServerBehaviour>
IServerComponent<INetworkManagerWrapper, ServerManager, NetworkConnection, IServerBehaviour>
Inherited Members
ScriptableObject.SetDirty()
ScriptableObject.CreateInstance<T>()
Object.GetEntityId()
Object.GetInstanceID()
Object.GetHashCode()
Object.InstantiateAsync<T>(T)
Object.InstantiateAsync<T>(T, Transform)
Object.InstantiateAsync<T>(T, Vector3, Quaternion)
Object.InstantiateAsync<T>(T, Transform, Vector3, Quaternion)
Object.Instantiate(Object, Vector3, Quaternion)
Object.Instantiate(Object, Vector3, Quaternion, Transform)
Object.Instantiate(Object)
Object.Instantiate(Object, Scene)
Object.Instantiate<T>(T, InstantiateParameters)
Object.Instantiate<T>(T, Vector3, Quaternion, InstantiateParameters)
Object.Instantiate(Object, Transform)
Object.Instantiate<T>(T)
Object.Instantiate<T>(T, Vector3, Quaternion)
Object.Instantiate<T>(T, Vector3, Quaternion, Transform)
Object.Instantiate<T>(T, Transform)
Object.Destroy(Object)
Object.DestroyImmediate(Object)
Object.DontDestroyOnLoad(Object)
Object.DestroyObject(Object)
Object.FindObjectsOfType<T>()
Object.FindObjectsByType<T>(FindObjectsSortMode)
Object.FindObjectsByType<T>(FindObjectsInactive, FindObjectsSortMode)
Object.FindObjectOfType<T>()
Object.FindFirstObjectByType<T>()
Object.FindAnyObjectByType<T>()
Object.FindFirstObjectByType<T>(FindObjectsInactive)
Object.FindAnyObjectByType<T>(FindObjectsInactive)
Object.FindObjectsByType<T>()
Object.FindObjectsByType<T>(FindObjectsInactive)
Object.ToString()
Object.name
Object.hideFlags

Properties

QueuedCount

Returns the current number of clients in the queue.

public int QueuedCount { get; }

Property Value

int

Methods

InitializeOnce()

Called once to initialize the behaviour. Must be implemented by derived classes.

public override ServerComponentInitializationStatus InitializeOnce()

Returns

ServerComponentInitializationStatus

Remarks

Behaviours that need to await I/O (database registration, for example) must override InitializeOnceAsync(CancellationToken) instead of blocking in here. The Unity main thread must never block on I/O: it is the thread that drains async continuations, so blocking it can deadlock startup before the transport ever binds.

IsAwaitingAdmission(NetworkConnection)

Returns whether conn is waiting in the queue or has just been admitted and is expected to re-handshake.

public bool IsAwaitingAdmission(NetworkConnection conn)

Parameters

conn NetworkConnection

Returns

bool

Remarks

The admitted-but-not-yet-re-handshaked window matters as much as the queue itself: an admitted client is popped off the queue, so it is no longer "queued", yet it is still unauthenticated and still waiting on us. Treating only the queue as exempt from the handshake timeout would let that window be disconnected out from under a client the server itself just invited back.

IsQueued(NetworkConnection)

Returns whether conn is currently waiting in the queue.

public bool IsQueued(NetworkConnection conn)

Parameters

conn NetworkConnection

Returns

bool

Remarks

Used by the authenticator's handshake-timeout sweep: a queued connection is intentionally left unauthenticated for as long as the wait lasts, which would otherwise look identical to a client that connected and never handshook.

OnClientDisconnected(NetworkConnection)

Removes a disconnected client from the queue and the recently-admitted set.

public void OnClientDisconnected(NetworkConnection conn)

Parameters

conn NetworkConnection

Remarks

Preferred over the ClientId-only overload when the caller still holds the connection: the entry goes immediately rather than lingering until the next purge sweep, which keeps reported positions and the queue count honest and stops the admission loop from having to step over it.

Must be called on the main thread — the queue itself is not thread-safe, which is why the ClientId-only overload deliberately touches nothing but the concurrent recently-admitted set.

OnClientDisconnected(int)

Immediately removes a disconnected client from both the queue and the recently-admitted set. Call from connection-stopped handlers to prevent wasted admission ticks on dead connections.

public void OnClientDisconnected(int clientId)

Parameters

clientId int

The FishNet client ID that disconnected.

OnDeinitialize()

Called when the behaviour is being deinitialized. Must be implemented by derived classes.

public override void OnDeinitialize()

OnUpdate(float)

Override this method in derived classes that need per-frame updates. Guaranteed to run only when the behaviour is initialized and Server is non-null.

protected override void OnUpdate(float deltaTime)

Parameters

deltaTime float

Time elapsed since last frame.

TryEnqueue(NetworkConnection)

Attempts to enqueue a connection that was deferred by the auth cap. Returns true if the client was queued; false if the queue is full and the client should be rejected outright.

public bool TryEnqueue(NetworkConnection conn)

Parameters

conn NetworkConnection

The network connection to queue.

Returns

bool

true if queued; false if the queue is at capacity.