Interface IHotkeySystemRuntimeData
- Namespace
- FishMMO.Server.Core.World.SceneServer
- Assembly
- FishMMO.Server.dll
Runtime state for hotkey ingress guards and pending hotkey persistence.
public interface IHotkeySystemRuntimeData : IRuntimeDataContainer, IServerComponent
Properties
IngressGuard
Shared ingress guard for per-connection per-operation debounce and in-flight tracking.
IngressGuard IngressGuard { get; }
Property Value
Methods
BuildRows(long, IReadOnlyList<HotkeyData>)
Turns a bar into the rows that persist it, one per slot, each stamped with a fresh NextHotkeyVersion().
List<CharacterHotkeyData> BuildRows(long characterID, IReadOnlyList<HotkeyData> hotkeys)
Parameters
characterIDlongThe owning character.
hotkeysIReadOnlyList<HotkeyData>The bar.
Returns
- List<CharacterHotkeyData>
One row per slot.
Remarks
EVERY slot, the empty ones included. The rows are keyed (character_id, slot) and
the upsert has no delete path, so writing only the occupied slots would leave a cleared
slot showing its previous binding forever.
DrainHotkeyWrites(List<KeyValuePair<long, HotkeyData[]>>)
Moves every staged snapshot into destination and empties the stage.
bool DrainHotkeyWrites(List<KeyValuePair<long, HotkeyData[]>> destination)
Parameters
destinationList<KeyValuePair<long, HotkeyData[]>>List to receive the staged snapshots.
Returns
- bool
True if anything was drained.
NextHotkeyVersion()
Produces the next strictly-increasing persistence version for a hotkey row.
long NextHotkeyVersion()
Returns
- long
A monotonic version value.
Remarks
The hotkey upsert is gated WHERE EXCLUDED.version > character_hotkey.version,
so a write only lands if it carries a strictly larger version than whatever is already
in the row. Nothing in the runtime tracked a hotkey version at all — the load path
reads the column and discards it — so the version has to be derived rather than
remembered.
DateTime.UtcNow.Ticks supplies that: it is larger than every version any
previous session wrote, and the running maximum below keeps it strictly increasing
even when two writes land inside one tick of clock resolution. It is deliberately NOT
long.MaxValue — the item layer's per-slot poisoning bug (audit CRIT-2) is
exactly what happens when a "make sure this write wins" sentinel is stamped into a
version column: the row becomes permanently unwritable.
StageHotkeyWrite(long, IReadOnlyList<HotkeyData>)
Records the character's current hotkey bar as the next thing to be written to the database, replacing any earlier unwritten snapshot for that character.
void StageHotkeyWrite(long characterID, IReadOnlyList<HotkeyData> hotkeys)
Parameters
characterIDlongThe character whose bar changed.
hotkeysIReadOnlyList<HotkeyData>The character's live hotkey list. Copied, not retained.
Remarks
Coalescing by character is deliberate. Dragging one ability along a twelve-slot bar produces a dozen accepted requests in a couple of seconds, and each one would otherwise be its own round trip to Postgres. Only the newest snapshot can be correct, so keeping only the newest is both cheaper and more accurate.
TakeDepartingBar(long, IReadOnlyList<HotkeyData>)
The departing character's whole live bar as rows, for the save that runs before its session is released; anything staged for it is dropped, since this supersedes it. Main thread only.
List<CharacterHotkeyData> TakeDepartingBar(long characterID, IReadOnlyList<HotkeyData> liveBar)
Parameters
characterIDlongThe departing character.
liveBarIReadOnlyList<HotkeyData>Its bar as it stands.
Returns
- List<CharacterHotkeyData>
One row per slot, or null when it has no bar.
Remarks
The bar is written by the character's own departure — CharacterSystem's
save-and-release, the reattach, the shutdown flush — inside the work that ends in the
release, under the claim it quotes. It used to be flushed from OnDisconnect as a
separate write, and from this system's own teardown, which runs before the character
system's shutdown flush releases every claim: once every hotkey write is
ownership-gated, a write that lands after its release is refused and lost, not merely
late.
The LIVE bar, not the stage: a write that failed earlier is re-staged only on the next pump, which a departing character does not get, so the stage alone could miss it.
TryDrainHotkeyWrite(long, out HotkeyData[])
Removes and returns the staged snapshot for one character, if any.
bool TryDrainHotkeyWrite(long characterID, out HotkeyData[] hotkeys)
Parameters
characterIDlongThe character to drain.
hotkeysHotkeyData[]The staged snapshot.
Returns
- bool
True if a snapshot was staged for that character.