Send chunks to players connected to server

This commit is contained in:
2026-09-28 11:14:40 -03:00
parent 677ad8115a
commit ded9a7e5d0
26 changed files with 920 additions and 357 deletions
+5 -1
View File
@@ -16,7 +16,11 @@ let next_download = 1;
function post(message: GameToHost) {
// the chunks are moved to the host, not copied
const transfer = message.type === "save" ? message.save.chunks.map((chunk) => chunk.data.buffer) : [];
const transfer = message.type === "save"
? message.save.chunks.map((chunk) => chunk.data.buffer)
: message.type === "send" && typeof message.data !== "string"
? [message.data.buffer]
: [];
self.postMessage(message, transfer);
}