Table of Contents

Class PendingNameRequests

Namespace
FishMMO.Client
Assembly
FishMMO.Client.dll

The client's name requests of one kind: who is waiting on which ID, which IDs are due to be sent, and when each was last sent. Pure bookkeeping: no network, no Unity, main thread only.

public sealed class PendingNameRequests
Inheritance
PendingNameRequests
Inherited Members

Remarks

Coalesced, not sent per ask. Asking for a name used to send one request per ID the moment it was asked for, so opening a 100-member roster sent 100 requests in one frame (hot-path audit M18). An ask now only queues its ID; TakeBatch(double, int, List<long>) hands out the queue a batch at a time, and the caller sends each batch as one request.

Sent again on a later ask, never on its own. The server answers a request over its connection's budget with nothing, and a request sent to a scene server the client has since left is never answered either. An ID still waiting RetrySeconds after it was sent is queued again by the next ask for it, so a lost request costs one retry window and not the session. Nothing re-sends by timer: a name nobody asks for again is not worth the traffic.

"No such entity" is an answer. ResolveMissing(long, double) drops the callbacks that were waiting (they captured UI rows and characters, and would otherwise be held for the session while every later ask appended to the chain) and holds the ID's retry window, so a caller that asks for a deleted character every frame costs one request per window.

Constructors

PendingNameRequests(double)

Creates an empty set of requests.

public PendingNameRequests(double retrySeconds)

Parameters

retrySeconds double

See RetrySeconds.

Properties

QueuedCount

IDs due to go out in the next batch.

public int QueuedCount { get; }

Property Value

int

RetrySeconds

Seconds after it was sent (or answered "no such entity") before the next ask for an ID sends it again.

public double RetrySeconds { get; }

Property Value

double

WaitingCount

IDs something is waiting on.

public int WaitingCount { get; }

Property Value

int

Methods

Clear()

Forgets everything.

public void Clear()

Request(long, Action<string>, double)

Records an ask for an ID's name, and queues the ID to be sent if it is due.

public bool Request(long id, Action<string> callback, double now)

Parameters

id long

The ID whose name is wanted.

callback Action<string>

Receives the name when it arrives. Combined with any already waiting.

now double

The current time, in seconds.

Returns

bool

True if the ID was queued by this ask.

Resolve(long, out Action<string>)

A name arrived: hands back everything that was waiting on it, and forgets the ID.

public bool Resolve(long id, out Action<string> callbacks)

Parameters

id long

The ID answered.

callbacks Action<string>

Everything waiting on it, or null.

Returns

bool

True if anything was waiting.

ResolveMissing(long, double)

The server looked and there is no such entity: drops what was waiting without calling it, and holds the ID's retry window from now.

public bool ResolveMissing(long id, double now)

Parameters

id long

The ID answered.

now double

The current time, in seconds.

Returns

bool

True if anything was waiting.

TakeBatch(double, int, List<long>)

Takes up to max queued IDs to send now, and stamps each as sent. The rest stay queued, in order, for the next call.

public int TakeBatch(double now, int max, List<long> into)

Parameters

now double

The current time, in seconds.

max int

Most IDs to take.

into List<long>

Receives the IDs. Not cleared first.

Returns

int

The number taken.