Skip to content

workerSession beta ​

Function of @v12-engine/engine

ts
export declare function workerSession(worker: WorldWorkerLike, options: WorkerSessionOptions): Promise<WorkerSession>;

Plays a game in a worker, and seats this page's player at it: the worker's file calls serveWorld with the same game. Settles once the world is made there and its welcome is in; fails with what the worker said went wrong

const session = await workerSession(new Worker(new URL('./game.worker.ts', import.meta.url), type: 'module' ), rules: game, map )