Skip to content

Commit de5dc9a

Browse files
committed
Fix viewer: replace WebSocket with fetch polling
Co-Authored-By: claude-flow <ruv@ruv.net>
1 parent c1336c6 commit de5dc9a

File tree

1 file changed

+16
-10
lines changed
  • rust-port/wifi-densepose-rs/crates/wifi-densepose-pointcloud/src

1 file changed

+16
-10
lines changed

rust-port/wifi-densepose-rs/crates/wifi-densepose-pointcloud/src/stream.rs

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -122,17 +122,23 @@ async fn index() -> Html<String> {
122122
123123
let pointsMesh = null;
124124
125-
// WebSocket
126-
const ws = new WebSocket(`ws://${location.host}/ws`);
127-
ws.onmessage = (e) => {
128-
const data = JSON.parse(e.data);
129-
if (data.type === 'pointcloud' && data.splats) {
130-
updateSplats(data.splats);
131-
document.getElementById('stats').innerHTML =
132-
`Points: ${data.points}<br>Splats: ${data.splats.length}<br>FPS: 10`;
125+
// Poll API for updates (no WebSocket needed)
126+
async function fetchCloud() {
127+
try {
128+
const resp = await fetch('/api/splats');
129+
const data = await resp.json();
130+
if (data.splats) {
131+
updateSplats(data.splats);
132+
document.getElementById('stats').innerHTML =
133+
`Splats: ${data.count}<br>Timestamp: ${new Date(data.timestamp).toLocaleTimeString()}`;
134+
}
135+
} catch(e) {
136+
document.getElementById('stats').innerHTML = 'Error: ' + e.message;
133137
}
134-
};
135-
ws.onopen = () => { document.getElementById('stats').innerHTML = 'Connected'; };
138+
}
139+
fetchCloud();
140+
setInterval(fetchCloud, 1000); // refresh every second
141+
document.getElementById('stats').innerHTML = 'Loading...';
136142
137143
function updateSplats(splats) {
138144
if (pointsMesh) scene.remove(pointsMesh);

0 commit comments

Comments
 (0)