websockets.integration

Classes

WebsocketsApp

Add application-bound websocket broadcast communication.

Functions

websocket_csp_tween_factory(→ Callable[[CoreRequest], ...)

get_js_path(→ str)

get_websockets_asset(→ Iterator[str])

Module Contents

class websockets.integration.WebsocketsApp[source]

Bases: more.webassets.WebassetsApp

Add application-bound websocket broadcast communication.

To receive broadcast messages using JavaScript in the browser, include the asset ‘websockets’ and call openWebsocket.

To send broadcast messages, call send_websocket with a JSON-serializable message.

_websockets_client_url: str[source]
websockets_manage_url: str[source]
websockets_manage_token: str[source]
configure_websockets(*, websockets: dict[str, Any] | None = None, **cfg: Any) None[source]

Configures global websocket settings.

websockets_client_url(request: onegov.core.request.CoreRequest) str[source]

Returns the public websocket endpoint that can be used with JS.

Upgrades the scheme to wss if request URL is https and fills in netloc based on the request URL if missing.

property websockets_private_channel: str[source]

An unguessable channel ID used for broadcasting notifications through websockets to logged-in users.

This is not meant to be safe, do not broadcast sensitive information!

send_websocket(message: onegov.core.types.JSON_ro, channel: str | None = None) bool[source]

Sends an application-bound broadcast message to all connected clients.

websockets.integration.websocket_csp_tween_factory(app: WebsocketsApp, handler: Callable[[CoreRequest], Response]) Callable[[CoreRequest], Response][source]
websockets.integration.get_js_path() str[source]
websockets.integration.get_websockets_asset() Iterator[str][source]