Skip to content

Server

SimViewServer is the FastAPI app that serves a scene's model/states (or per-blob columnar endpoints) to the browser, and handles WebSocket live-push. Most users won't instantiate this directly — see SimulationScene.show(), LiveViewer, or the simview CLI instead.

simview.server.SimViewServer

SimViewServer(
    sim_path: str
    | Path
    | Sequence[str | Path]
    | None = None,
    data: dict | None = None,
    live: bool = False,
)

broadcast_frame async

broadcast_frame(frame: dict) -> None

Send one newly-pushed frame to every connected /ws/states client.

Must run on self.loop (the server thread's event loop) -- LiveViewer schedules this via asyncio.run_coroutine_threadsafe rather than calling it directly from the caller's thread. A dead/broken socket is dropped rather than allowed to raise, since one slow/gone client must never break the broadcast (or the caller's push_state) for the rest.