mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 18:47:35 +00:00
Add standalone POC comparing WebRTC DataChannel vs Socket.IO
Self-contained test under poc-webrtc/ that does not touch the game. Spins up an Express + WebSocket signaling + node-datachannel server alongside a Socket.IO server, serves a simple browser client that runs the same game-like traffic pattern (14Hz worldUpdates, input events, ping/pong) over either transport based on a URL flag. Captures per-session stats to a JSONL file and ships an analyze.js that prints a per-(transport, phase) summary of RTT percentiles, receive rate, and seq-gap counts so the TCP-vs-UDP-style comparison becomes quantitative rather than eyeball. Confirms node-datachannel installs and works on this platform and that the dual-channel (reliable + unreliable) pattern is feasible to maintain — both prerequisites for the real integration.
This commit is contained in:
parent
71e4b4e847
commit
47faae81e5
9 changed files with 2407 additions and 0 deletions
20
poc-webrtc/public/socketio-client.js
Normal file
20
poc-webrtc/public/socketio-client.js
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
// Socket.IO comparison client. Uses the same POC.attach() / POC.handleMessage()
|
||||
// interface as the WebRTC client so the comparison is apples-to-apples.
|
||||
|
||||
(function () {
|
||||
const POC = window.POC;
|
||||
POC.setStatus("connecting (socketio)…", "wait");
|
||||
|
||||
const sock = io({ path: "/socketio" });
|
||||
sock.on("connect", () => {
|
||||
POC.log("socket.io connected " + sock.id);
|
||||
POC.setStatus("connected (socket.io)", "ok");
|
||||
POC.attach((obj) => sock.emit("msg", obj));
|
||||
});
|
||||
sock.on("disconnect", () => {
|
||||
POC.log("socket.io disconnected");
|
||||
POC.setStatus("disconnected", "bad");
|
||||
});
|
||||
sock.on("connect_error", (err) => POC.log("socket.io error: " + err.message));
|
||||
sock.on("msg", (data) => POC.handleMessage(data));
|
||||
})();
|
||||
Loading…
Add table
Add a link
Reference in a new issue