bundle.website.builtin.components.websocket.base.backend¶
Attributes¶
Functions¶
|
Build a websocket router bound to endpoint. |
|
Run one websocket session with composable async tasks. |
|
Return a task factory that runs tick periodically every seconds. |
|
Consume and discard incoming text frames until disconnect. |
|
Return a task factory that reads JSON objects and forwards them to handle. |
|
|
|
Default keepalive protocol: keepalive -> keepalive_ack. |
Module Contents¶
- bundle.website.builtin.components.websocket.base.backend.WebSocketHandler¶
- bundle.website.builtin.components.websocket.base.backend.TaskFactory¶
- bundle.website.builtin.components.websocket.base.backend.create_router(endpoint: str, handler: WebSocketHandler | None = None) fastapi.APIRouter¶
Build a websocket router bound to endpoint.
- Parameters:
endpoint – FastAPI websocket path (for example /ws/ecc).
handler – Websocket coroutine handler. Defaults to keepalive_loop.
- Returns:
APIRouter with one websocket entrypoint.
- async bundle.website.builtin.components.websocket.base.backend.run_websocket(websocket: fastapi.WebSocket, *task_factories: TaskFactory) None¶
Run one websocket session with composable async tasks.
The function accepts the connection, starts all tasks, waits for completion, and performs robust cancellation cleanup when the socket closes.
- bundle.website.builtin.components.websocket.base.backend.every(seconds: float, tick: TaskFactory) TaskFactory¶
Return a task factory that runs tick periodically every seconds.
- async bundle.website.builtin.components.websocket.base.backend.drain_text(websocket: fastapi.WebSocket) None¶
Consume and discard incoming text frames until disconnect.
- bundle.website.builtin.components.websocket.base.backend.receive_json(handle: collections.abc.Callable[[fastapi.WebSocket, dict], collections.abc.Awaitable[None]]) TaskFactory¶
Return a task factory that reads JSON objects and forwards them to handle.