mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
Route gameCommand traffic through WebRTC unreliable DataChannel
Socket.IO (TCP) holds back later packets while it retransmits a lost one, which stalls worldUpdate delivery on lossy long-distance links — exactly the pattern game state suffers worst from. WebRTC DataChannels in unreliable mode (ordered:false, maxRetransmits:0) drop late packets instead of queueing them, which is what we want for high-frequency state sync. Adds a per-user WebRTCTransport on top of the existing Socket.IO connection. Socket.IO stays in charge of bootstrap, signaling (SDP/ICE exchange), and control messages — only gameCommand payloads get routed onto the unreliable channel once it's open. If WebRTC fails to negotiate, gameCommand transparently falls back to Socket.IO, so the game keeps working unchanged. A new StatsLogger writes per-session JSONL events (session_start, webrtc_ready with negotiation time, per-second stats with transport, RTT samples, recv/send rates, seq gaps) so we can compare real-world runs (e.g. Germany server <-> Korea client) instead of guessing. URL flag ?webrtc=0 forces fallback for A/B testing. scripts/webrtc-browser-test.js spins up a headless Chromium against a freshly-started server and asserts the unreliable channel opens and gameCommand traffic actually rides it.
This commit is contained in:
parent
47faae81e5
commit
a0481ed867
9 changed files with 1412 additions and 138 deletions
|
|
@ -115,6 +115,13 @@ function (Settings, nc, Screenfull, Graph, pointerLockManager) {
|
|||
li.appendChild(this.ping);
|
||||
this.devToolsContainer.appendChild(li);
|
||||
|
||||
// create Transport: container
|
||||
li = document.createElement("li");
|
||||
this.transport = document.createElement("label");
|
||||
this.transport.innerHTML = "transport:?";
|
||||
li.appendChild(this.transport);
|
||||
this.devToolsContainer.appendChild(li);
|
||||
|
||||
|
||||
// create debug mode
|
||||
li = document.createElement("li");
|
||||
|
|
@ -165,6 +172,10 @@ function (Settings, nc, Screenfull, Graph, pointerLockManager) {
|
|||
// this.pingGraph.addValue(ping);
|
||||
};
|
||||
|
||||
DomController.prototype.setTransport = function(name) {
|
||||
if (this.transport) this.transport.innerHTML = "transport:" + name;
|
||||
};
|
||||
|
||||
DomController.prototype.getCanvasContainer = function () {
|
||||
var container = document.getElementById(Settings.CANVAS_DOM_ID);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue