Pixi’VN
indexFunctions

Function: handleGameWorkerMessage()

> handleGameWorkerMessage(request): Promise<GameWorkerResponse>

Defined in: src/worker/handleGameWorkerMessage.ts:26

The worker-side half of the GameWorkerManager protocol. The game project creates its own Worker (so it controls the bundler-specific setup) and points its message handling here:

// game-worker.ts, built as its own entry by the project's bundler
import { handleGameWorkerMessage } from "@drincs/pixi-vn/worker";

self.onmessage = async (event) => {
    const response = await handleGameWorkerMessage(event.data);
    if (response) self.postMessage(response);
};

A third-party library sharing this same worker (see registerGameWorkerHandler) just needs its own worker-side registration module imported alongside this one, in that same file.

Everything this processes is plain, structured-clone-safe data by construction - it never touches PixiJS/canvas/audio, which only exist on the main thread.

Parameters

request

GameWorkerRequest

Returns

Promise<GameWorkerResponse>

On this page