diff options
| author | Osmium Sorcerer <os@sof.beauty> | 2026-03-16 14:12:22 +0000 |
|---|---|---|
| committer | Osmium Sorcerer <os@sof.beauty> | 2026-06-06 03:06:43 +0000 |
| commit | baa39f317e978d02b7b1c0a5fd8c7c3b3585de69 (patch) | |
| tree | 9fc0fa19725deea4a66857639b83646facaf31a7 /webAO | |
| parent | 5e6efbad8ebbbfbf2f39c9b6d0e8069c6132e6aa (diff) | |
Remove CH-sending timer
CH is an application-level keepalive packet that clients periodically
send for two reasons:
1. It tells the server they're still connected, preventing timeouts.
2. By measuring latency between sending CH and receiving CHECK, a client
can display ping.
Keepalive is redundant because WebSocket can handle that via PING frames on a
transport layer. WebAO also completely ignores CHECK and sends CH every
five seconds, which is superfluous (AO2 Client sends it once every 45
seconds, in comparison).
Sending CH via `setInterval` was also problematic: browsers seem to
throttle it when the tab becomes inactive, preventing periodic pings and
leading to the server disconnecting inactive browser clients.
Diffstat (limited to 'webAO')
| -rw-r--r-- | webAO/client.ts | 11 | ||||
| -rw-r--r-- | webAO/client/sender/index.ts | 3 | ||||
| -rw-r--r-- | webAO/client/sender/sendCheck.ts | 8 |
3 files changed, 1 insertions, 21 deletions
diff --git a/webAO/client.ts b/webAO/client.ts index ca53173f..94caf0cb 100644 --- a/webAO/client.ts +++ b/webAO/client.ts @@ -143,7 +143,6 @@ class Client extends EventEmitter { selectedEmote: number; selectedEvidence: number; sender: ISender; - checkUpdater: any; _lastTimeICReceived: any; viewport: Viewport; partial_packet: boolean; @@ -207,7 +206,6 @@ class Client extends EventEmitter { this.resources = getResources(AO_HOST, theme); this.selectedEmote = -1; this.selectedEvidence = -1; - this.checkUpdater = null; this.sender = sender; this.viewport = masterViewport(); this._lastTimeICReceived = new Date(0); @@ -266,9 +264,6 @@ class Client extends EventEmitter { document.getElementById("client_charselect").remove(); document.getElementById("client_ooc").remove(); } - if (mode !== "replay") { - this.checkUpdater = setInterval(() => this.sender.sendCheck(), 5000); - } } /** @@ -384,12 +379,8 @@ class Client extends EventEmitter { this.cleanup(); } - /** - * Stop sending keepalives to the server. - */ cleanup() { - clearInterval(this.checkUpdater); - if (this.serv) this.serv.close(); + this.serv.close(); } /** diff --git a/webAO/client/sender/index.ts b/webAO/client/sender/index.ts index e218b6bc..b9e2b4f4 100644 --- a/webAO/client/sender/index.ts +++ b/webAO/client/sender/index.ts @@ -1,7 +1,6 @@ import { sendIC } from "./sendIC"; import { sendSelf } from "./sendSelf"; import { sendServer } from "./sendServer"; -import { sendCheck } from "./sendCheck"; import { sendHP } from "./sendHP"; import { sendOOC } from "./sendOOC"; import { sendCharacter } from "./sendCharacter"; @@ -43,7 +42,6 @@ export interface ISender { ) => void; sendSelf: (message: string) => void; sendServer: (message: string) => void; - sendCheck: () => void; sendHP: (side: number, hp: number) => void; sendOOC: (message: string) => void; sendCharacter: (character: number) => void; @@ -59,7 +57,6 @@ export const sender = { sendIC, sendSelf, sendServer, - sendCheck, sendHP, sendOOC, sendCharacter, diff --git a/webAO/client/sender/sendCheck.ts b/webAO/client/sender/sendCheck.ts deleted file mode 100644 index 7eb47510..00000000 --- a/webAO/client/sender/sendCheck.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { client } from "../../client"; - -/** - * Sends a keepalive packet. - */ -export const sendCheck = () => { - client.sender.sendServer(`CH#${client.charID}#%`); -}; |
