Skip to main content

Module ws

Module ws 

Source
Expand description

A tiny dependency-free WebSocket bridge so the scheduler can reach a browser tab as a device. Browsers can’t accept raw TCP, but a tab connects out via WebSocket — so we run a small HTTP server that serves the worker page + wasm and upgrades /ws to a WebSocket. Op frames (the same host-buffer format as Device::Remote) ride the socket to the tab, which computes on WebGPU and sends the result back. RFC 6455 handshake (SHA-1 + base64) and frame codec implemented inline.

Structs§

Bridge
Serve site_dir over HTTP and hand back the first browser tab that connects to /ws.
WsConn
One WebSocket connection to a browser tab. Binary messages only.

Functions§

start
Start the bridge on an ephemeral localhost port, serving files from site_dir.