webstation-broker
DeveloperPython reference

callback

Exit-time save archive push to the parent (RomM).

Exit-time save archive push to the parent (RomM).

The broker is normally served same-origin under the parent's SUBFOLDER, so activate derives the callback base URL from the request that launched the session; an explicit callback.base_url in the activate payload overrides it for split-origin deployments.

attributelog
= logging.getLogger(__name__)
funcredact_url(url) -> str

Drop any user:password@ from a URL, for logs and reports.

A split-origin callback.base_url may carry credentials in its userinfo; they authenticate the upload but have no business in the broker's log.

paramurlstr

The URL to redact.

Returns

str

The URL with its userinfo replaced by ***@, or unchanged when it has none.

funcpublic_view(callback) -> Optional[dict[str, Any]]

Return the callback info that is safe to echo in reports: everything but the token.

Any credentials in base_url are redacted as well (see redact_url).

paramcallbackOptional[dict[str, Any]]

The session's callback dict, or None when the session has none.

Returns

typing.Optional

A copy of callback without its token key, or None when callback is

funcpush_save_archive(callback, zip_bytes, filename, sess) -> dict[str, Any]

POST the save archive to the callback origin as multipart form data.

Failures are reported, never raised: exit teardown must finish regardless.

paramcallbackdict[str, Any]

The session's callback dict; base_url is required and token, when present, is sent as a bearer token.

paramzip_bytesbytes

The archive body.

paramfilenamestr

The filename to attach to the multipart archive field.

paramsessdict[str, Any]

The game the archive belongs to: id (its game id), emulator, rom and, optionally, room_id, all sent as form fields alongside the archive. session_id carries the game id, which is the room id for a room's first game, so a parent that predates game swap files it as before; room_id is only sent when it differs.

Returns

dict

A report of the shape {"mode": "uploaded" | "failed", "ok": bool, "url": str, ...},