simvx.graphics.streaming.server

WebSocket JPEG streaming server: captures frames from the Vulkan renderer and streams to browsers.

Module Contents

Classes

StreamingServer

WebSocket JPEG streaming server for SimVX.

Data

API

simvx.graphics.streaming.server.log

‘getLogger(…)’

simvx.graphics.streaming.server.__all__

[‘StreamingServer’]

class simvx.graphics.streaming.server.StreamingServer(host: str = '127.0.0.1', port: int = 8080, quality: int = 85, fps: int = 30)

WebSocket JPEG streaming server for SimVX.

Serves a browser client and streams rendered frames as JPEG over WebSocket. Input events from the browser are forwarded to the engine’s Input singleton. It listens on loopback by default; pass host to serve another interface ("0.0.0.0" for all).

Usage::

server = StreamingServer(port=8080)
app = App(width=1280, height=720, visible=False)
app.run_streaming(MyGameScene(), server)

Initialization

start(width: int, height: int) → None

Start the streaming server in a background thread.

stop() → None

Stop the streaming server and close all WebSocket connections.

push_frame(pixels: numpy.ndarray) → None

Push a captured frame for streaming. Thread-safe, called from the engine’s main loop.

Drops the frame if the encoder is behind (non-blocking). Drops are counted in

Attr:

dropped_frames and warned about at a limited rate.

drain_input() → list[dict]

Drain all queued input events. Called from the main thread.

has_clients() → bool

Whether any browser clients are connected.

property dropped_frames: int

Frames discarded because the encoder could not keep up with the render loop.

property dropped_inputs: int

Browser input events discarded because the main thread did not drain them in time.