bundle.website.builtin.components.websocket.base¶
Submodules¶
Classes¶
Base websocket component with default params and shared assets. |
|
Shared websocket parameters for component instances. |
|
Shared params for GPX websocket components. |
|
Base class for graph-oriented websocket components. |
|
Typed dispatcher that routes websocket payloads by their type field. |
|
Outgoing keepalive acknowledgement. |
|
Outgoing protocol error message. |
|
Incoming keepalive ping message. |
Functions¶
|
Consume and discard incoming text frames until disconnect. |
|
Return a task factory that runs tick periodically every seconds. |
|
Default keepalive protocol: keepalive -> keepalive_ack. |
|
Return a task factory that reads JSON objects and forwards them to handle. |
|
Run one websocket session with composable async tasks. |
Package Contents¶
- async bundle.website.builtin.components.websocket.base.drain_text(websocket: fastapi.WebSocket) None¶
Consume and discard incoming text frames until disconnect.
- bundle.website.builtin.components.websocket.base.every(seconds: float, tick: TaskFactory) TaskFactory¶
Return a task factory that runs tick periodically every seconds.
- async bundle.website.builtin.components.websocket.base.keepalive_loop(websocket: fastapi.WebSocket) None¶
Default keepalive protocol: keepalive -> keepalive_ack.
- bundle.website.builtin.components.websocket.base.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.
- async bundle.website.builtin.components.websocket.base.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.
- class bundle.website.builtin.components.websocket.base.WebSocketBaseComponent(/, **data: Any)¶
Bases:
bundle.website.core.component.ComponentBase websocket component with default params and shared assets.
- params: WebSocketComponentParams = None¶
- classmethod component_asset_paths_for(component_file: str | pathlib.Path, *, asset_filenames: collections.abc.Iterable[str] | None = None) list[str]¶
- async handle_websocket(websocket: fastapi.WebSocket) None¶
Default websocket handler (keepalive protocol).
- build_routers()¶
Attach the component websocket route using the configured endpoint.
- class bundle.website.builtin.components.websocket.base.WebSocketComponentParams(/, **data: Any)¶
Bases:
bundle.core.data.DataShared websocket parameters for component instances.
- class bundle.website.builtin.components.websocket.base.GPXComponentParams(/, **data: Any)¶
Bases:
bundle.website.builtin.components.graphic.threeD.GraphicThreeDComponentParams,bundle.website.builtin.components.websocket.base.component.WebSocketComponentParamsShared params for GPX websocket components.
- class bundle.website.builtin.components.websocket.base.GPXWebSocketBaseComponent(/, **data: Any)¶
Bases:
bundle.website.builtin.components.websocket.base.component.WebSocketBaseComponent,bundle.website.builtin.components.graphic.threeD.GraphicThreeDComponentBase class for graph-oriented websocket components.
- params: GPXComponentParams = None¶
- class bundle.website.builtin.components.websocket.base.MessageRouter¶
Typed dispatcher that routes websocket payloads by their type field.
- on(message_type: type[bundle.website.core.ws_messages.MessageT], handler: collections.abc.Callable[[fastapi.WebSocket, bundle.website.core.ws_messages.MessageT], collections.abc.Awaitable[None]]) MessageRouter¶
Register a callback for a Data message model.
- class bundle.website.builtin.components.websocket.base.AckMessage(/, **data: Any)¶
Bases:
bundle.core.data.Data,bundle.website.core.ws_messages.WebSocketDataMixinOutgoing keepalive acknowledgement.
- type: Literal['keepalive_ack'] = 'keepalive_ack'¶
- class bundle.website.builtin.components.websocket.base.ErrorMessage(/, **data: Any)¶
Bases:
bundle.core.data.Data,bundle.website.core.ws_messages.WebSocketDataMixinOutgoing protocol error message.
- type: Literal['error'] = 'error'¶
- class bundle.website.builtin.components.websocket.base.KeepAliveMessage(/, **data: Any)¶
Bases:
bundle.core.data.Data,bundle.website.core.ws_messages.WebSocketDataMixinIncoming keepalive ping message.
- type: Literal['keepalive'] = 'keepalive'¶