@zaisma/cli 0.49.0 → 0.50.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -139,7 +139,7 @@ zaisma-server/
|
|
|
139
139
|
|
|
140
140
|
- **Plain JavaScript ES modules:** `zaisma-server/index.js` default-exports the game server above, and can import the folder's other files by relative path: `.js` code, `.json` data (`import levels from "./levels.json"`) and `.wasm` WebAssembly, like a physics engine (`import mod from "./physics.wasm"` gives a `WebAssembly.Module`; `new WebAssembly.Instance(mod, imports)` starts it). Packages from npm (`import "lodash"`) and TypeScript need a build step: bundle into one `zaisma-server.js` at the top of the upload instead (`npx esbuild server.ts --format=esm --bundle --outfile=zaisma-server.js`), or into `zaisma-server/index.js` when it has data files. Up to 500 files and 32 MB in all, data files included (`GAME_SERVER_LIMITS`).
|
|
141
141
|
- **Data files:** every other file in `zaisma-server/` (`.bin`, `.gz`, `.txt`, anything but `.js`, `.json` and `.wasm`) ships beside the code as a data file, like prebuilt navigation meshes, level geometry or a dictionary. `room.readDataFile("maps/docks.bin")` (or `server.readDataFile` in `onRequest`, `onSchedule` and `onWebhook`) answers it as an `ArrayBuffer`, by its path from `zaisma-server/`: no base64, no download, and nothing on the meter, since it comes with the code. It's the same `ArrayBuffer` every time, shared by every room of the version running in the same place, so read it and never change it; keep what you build from it in a variable outside the handlers (`const meshes = new Map()`) and every room there shares it too. A path with no data file throws a `GameServerError` `bad_room_call`. On your own server, data files are read from the game server's folder (`--data-folder`, or `startServer({ dataFolder })`; `zaisma-server` by default).
|
|
142
|
-
- **Time to start:** each call into the game server, a tick with the messages since the last one, a join, a request, has 50 ms of CPU (`GAME_SERVER_LIMITS.maximumCallCpuDurationMs`). A start has 5 seconds (`maximumStartCpuDurationMs`): loading the game server, `setup`, `onRestored`, and a real-time room's first tick after
|
|
142
|
+
- **Time to start:** each call into the game server, a tick with the messages since the last one, a join, a request, has 50 ms of CPU (`GAME_SERVER_LIMITS.maximumCallCpuDurationMs`). A start has 5 seconds (`maximumStartCpuDurationMs`): loading the game server, `setup`, `onRestored`, and a real-time room's first tick after any of them, or after the room puts its state back in a fresh copy of the game server (one that started again and lost its memory, or one opened again after a stop), whether or not the game has `onRestored`, so build what the match needs once (a map's navigation, its collision) in that first tick, not spread over many. The game server's top-level code, outside its handlers, has Cloudflare's 1 second as it loads (`maximumLoadCpuDurationMs`), so heavy work goes in that first tick. One copy of the game server, shared by the version's rooms in one place, has 128 MB of memory (`maximumMemorySizeBytes`), its data files included. Every second of CPU is on the game's hosting meter, starts included.
|
|
143
143
|
- **Sealed off:** nothing of Zaisma's but its own game's database and secrets, and other servers only on the hosts you list (below), so it talks to its players through `room` and its answers to their requests. State is plain JSON.
|
|
144
144
|
- **Private:** players never get its files; the game domain refuses `zaisma-server/` and `zaisma-server.js`.
|
|
145
145
|
- **Real-time rooms batch input:** in a room with `ticksPerSec`, the state stays inside the sandbox, and players' messages and bytes reach `onMessage` and `onBytes` just before the next `onTick`, in the order they came, with what they send going out then (at most a tick later). A handler that throws leaves the rest of the batch to run, and what it changed in the state before throwing stays, as on your own server, where they run as they come. Either way a room's handlers run one at a time: one that awaits (the database, say) finishes before the room's next message, bytes or tick reaches the game server.
|