transfer test

This commit is contained in:
evanpelle
2025-12-24 15:17:55 -08:00
parent 28e22c9ca8
commit 2536772997
2 changed files with 30 additions and 4 deletions
+4 -3
View File
@@ -111,7 +111,7 @@ class Client {
private turnstileTokenPromise: Promise<{
token: string;
createdAt: number;
}> | null = null;
} | null> | null = null;
constructor() {}
@@ -712,7 +712,7 @@ document.addEventListener("DOMContentLoaded", () => {
async function getTurnstileToken(): Promise<{
token: string;
createdAt: number;
}> {
} | null> {
// Wait for Turnstile script to load (handles slow connections)
let attempts = 0;
while (typeof window.turnstile === "undefined" && attempts < 100) {
@@ -721,7 +721,8 @@ async function getTurnstileToken(): Promise<{
}
if (typeof window.turnstile === "undefined") {
throw new Error("Failed to load Turnstile script");
console.error("Failed to load Turnstile script");
return null;
}
const config = await getServerConfigFromClient();
+26 -1
View File
@@ -1,7 +1,12 @@
import version from "../../../resources/version.txt";
import { createGameRunner, GameRunner } from "../GameRunner";
import { replacer } from "../Util";
import { FetchGameMapLoader } from "../game/FetchGameMapLoader";
import { ErrorUpdate, GameUpdateViewData } from "../game/GameUpdates";
import {
ErrorUpdate,
GameUpdateType,
GameUpdateViewData,
} from "../game/GameUpdates";
import {
AttackAveragePositionResultMessage,
InitializedMessage,
@@ -22,10 +27,30 @@ function gameUpdate(gu: GameUpdateViewData | ErrorUpdate) {
if (!("updates" in gu)) {
return;
}
const startPost = performance.now();
sendMessage({
type: "game_update",
gameUpdate: gu,
});
const durationPost = performance.now() - startPost;
if (gu.tick % 10 !== 0) {
return;
}
console.log(`post message duration: ${durationPost} ms`);
console.log(`tile size: ${gu.packedTileUpdates.length}`);
for (const u in gu.updates) {
const size = JSON.stringify(gu.updates[u], replacer).length / 1024;
if (size > 10) {
console.log(`type: ${GameUpdateType[u]}, size: ${size}`);
}
}
const start = performance.now();
console.log(`total size: ${JSON.stringify(gu, replacer).length / 1024}`);
const duration = performance.now() - start;
console.log(`serialization time: ${duration} ms`);
}
function sendMessage(message: WorkerMessage) {