mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-27 06:02:46 +00:00
transfer test
This commit is contained in:
+4
-3
@@ -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();
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user