Replies: 2 comments
|
I've been really busy with a lot of IRL stuff, so I've had little time to work on this. My initial attempt at an implementation did work, but it wasn't as optimized as I would've liked. Given that it didn't meet the quality bar I set for myself going in and that I'll be tied up for the foreseeable future, I'll leave it to the tosu devs to decide whether they want to implement this or just close the issue. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
description
In the current architecture of the
/api/ingameendpoint, the parent Electron window instantiates multiple overlays as<iframe>elements. Currently, each of these overlays independently establishes its own WebSocket connection to the Tosu API viaWebSocketManager.The Problem
This 1:N architecture creates significant performance bottlenecks:
JSON.parse()operations on the same data payload.Proposed Solution
Refactor
ingame.jsto act as a centralized data broker. Instead of each child iframe managing its own connection, the parent window should maintain a single WebSocket connection and distribute data to child overlays viawindow.postMessage.Implementation Details
1. Parent Window (
ingame.js)?ingame=true).postMessage.2. Client Library (
socket.js)createConnectionmethod to check for theingame=trueURL parameter.window.addEventListener('message', ...)listener.3. Filter Strategy
Backward Compatibility
Legacy overlays (e.g., those built for gosumemory or using hardcoded socket logic) that do not support the
ingame=trueprotocol will ignore the parameter and continue to establish their own WebSocket connections. This ensures no breaking changes for existing community content.Expected Results
JSON.parseops: FromN(number of overlays) to1 + M(where M is the number of legacy overlays).All reactions