SavePort
Where saves live; the host app supplies it. who is a seat key (“u:” for one room’s own world save (save “room”: a board found again by its 12-letter code). slot is the app’s stable key for the game. store(…, null) deletes. Keep a world at least saveDays (90).
Methods
Section titled “Methods”load()
Section titled “load()”load(
scope,slot,who,meta?):Promise<{at:number;data:unknown;v?:number; } |null>
null = nothing saved. Reject only when the save could not be read (the hub then writes nothing over it and tries again later). meta.claim (world saves): the room session that now owns this save. A store shared by several processes (blue/green) should remember it BEFORE reading and from then on refuse a world write or delete whose meta.session is another one (an error with code “superseded”): a late write from a room that handed the save on can then never land over the new owner’s game. fileSaves does this.
Parameters
Section titled “Parameters”string
string
string | null
claim?
Section titled “claim?”string
Returns
Section titled “Returns”Promise<{ at: number; data: unknown; v?: number; } | null>
store()
Section titled “store()”store(
scope,slot,who,data,meta?):Promise<void>
meta.session: one id per room session for world saves, so a store that keeps an earlier copy can take it once per session. meta.v: the game’s save format number (multiplayer.saveVersion), kept with the data and given back by load (a file without it counts as 1).
Parameters
Section titled “Parameters”string
string
string | null
unknown
session?
Section titled “session?”string
number
Returns
Section titled “Returns”Promise<void>