feat(net): F3 network overlay - ping graph and where lag comes from (you, opponent, server)

This commit is contained in:
Benjamin Oezcan
2026-11-19 14:30:40 +01:00
parent a8d6158384
commit 695cf77afc
8 changed files with 251 additions and 4 deletions

View File

@@ -129,6 +129,7 @@
s.onopen = () => s.send(JSON.stringify({ t: 'hello', v: RC.Proto.VERSION, token: t }));
s.onmessage = ev => {
let msg; try { msg = JSON.parse(ev.data); } catch (e) { return; }
msg._bytes = ev.data.length; // for the network overlay (bandwidth)
if (msg.t === 'welcome') { isOpen = true; backoff = 1000; emit('open', msg); }
if (msg.t === 'error' && (msg.code === 'OUTDATED' || msg.code === 'REPLACED')) { want = false; emit(msg.code === 'OUTDATED' ? 'outdated' : 'replaced', msg); }
if (msg.t === 'error' && msg.code === 'UNAUTH' && session) session.exp = 0; // refresh before the retry