WorkerSession beta
Class of @v12-engine/engine
export declare class WorkerSession extends RemoteSessionA seat at a game run in a worker of this page (workerSession): a RemoteSession whose host is a message away, with what a game played in the page has besides: its pace held and stepped (speed, advance), a save of it (save), the checkpoint to start again from, what it says in its log, the debug tools' view, and where its time went
Members
about
about?: unknown;What the worker's file said of the world as the game started (ServeWorldOptions.about): plain data, none where it says nothing
advance
advance(ticks?: number): void;Asks the worker to step the held game by this many ticks
can
readonly can: SessionCan;Its pace held and stepped, saves of it, the debug tools' view where they are on, and where its time went and in which systems
checkpoint
checkpoint?: {
label: Message;
save: WorldSave;
};The label and save of the last checkpoint the worker's game took, to retry from
debug
get debug(): SessionDebug | undefined;The debug tools' view of the world, where they are on: over the session's own words, as a server's is
delay
get delay(): number;How far behind the newest tick the screen is shown, in ticks: one, and room for how unevenly they come (a tick that took long comes late). Less than over a wire, where two are kept in hand: there is no line to stall here
dispose
dispose(): void;Ends the game in the worker. The worker is the page's: it stays, for the next game, until the page ends it
heard
heard(said: FromWorker): void;What the worker said that is not the session's own text
log
log: Logger;What the world says (World.log), said again here: the page shows it with its own
onTold
onTold(listener: (data: unknown) => void): () => void;Hears what the worker's code tells the page (WorkerGameContext.tell): plain data, in order with the ticks. What it told before anyone listened is heard by the first listener, at once. Gives back what stops hearing it
received
received: number;Milliseconds the page took to take in what the worker sent, each time, evened out: its share of a game run there
reloadGame
reloadGame(): void;Asks the worker to take a new version of the game (hot reload): it loads the game again itself, as its file says (serveWorld reload), and puts it into its world
save
save(): Promise<WorldSave>;Asks the worker for a save of its world and resolves with it; rejects if the game ends first
speed
get speed(): number;
set speed(speed: number);The simulation speed multiplier the worker's game runs at, 0 pauses; setting it tells the worker
timing
timing(): {
tick: number;
tickMax: number;
send: number;
receive: number;
systems: SystemTiming[];
} | undefined;Where the worker's time went (tick, send and receive milliseconds and each system's), or undefined until it has said
wire
wire(post: (message: ToWorker) => void, log: Logger, stop: () => void): void;What workerSession gives it once it is made: the way to the worker, and what stops hearing it