BaseStreamingService
Interface a streaming service (websockets or webrtc) implements so the supervisor can start, stop, and route to either interchangeably.
Attributes
attributemode= nameFunctions
constructor__init__(name) -> NoneSource Code
def __init__(self, name: str) -> None:
self.mode = nameparamnamestrReturns
Nonefuncstart() -> NoneSet up resources and run the service's loops until stopped.
Source Code
@abstractmethod
async def start(self) -> None:
"""Set up resources and run the service's loops until stopped."""Returns
Nonefuncstop() -> NoneClean up resources and stop the service's loops.
Source Code
@abstractmethod
async def stop(self) -> None:
"""Clean up resources and stop the service's loops."""Returns
Nonefuncregister_routes(api_prefix, main_router) -> NoneRegister the service's absolute paths directly on the main router.
Source Code
@abstractmethod
def register_routes(self, api_prefix: str, main_router: web.UrlDispatcher) -> None:
"""Register the service's absolute paths directly on the main router.
Args:
api_prefix: Deployment subfolder prefix (empty when serving at root).
main_router: The application's router to register routes on.
"""
passparamapi_prefixstrDeployment subfolder prefix (empty when serving at root).
parammain_routerweb.UrlDispatcherThe application's router to register routes on.
Returns
Nonefuncannounce_print_document(name, size) -> NoneTell the controller pages that name waits in the print spool.
Source Code
@abstractmethod
async def announce_print_document(self, name: str, size: int) -> None:
"""Tell the controller pages that `name` waits in the print spool."""paramnamestrparamsizeintReturns
Nonefuncsessions() -> List[Dict[str, Any]]The pages connected to this transport: id, transport, role,
slot, display, connected_at and rtt_ms, the same keys on both.
Source Code
@abstractmethod
async def sessions(self) -> List[Dict[str, Any]]:
"""The pages connected to this transport: `id`, `transport`, `role`,
`slot`, `display`, `connected_at` and `rtt_ms`, the same keys on both."""Returns
typing.List[typing.Dict[str, typing.Any]]funcdisconnect_session(session_id) -> boolClose the page id names; False when it is not connected here.
Source Code
@abstractmethod
async def disconnect_session(self, session_id: str) -> bool:
"""Close the page `id` names; False when it is not connected here."""paramsession_idstrReturns
boolfuncuplink_session_conns() -> List[Tuple[Any, Optional[str], Optional[str]]](websocket, session token, peer ip) per connected client
session, for upload uplink gauging (UplinkGauge).
The websocket must send ping() frames, and the service's message
loop must run with autoping off, answer PING itself, and hand every
PONG to note_pong — the gauge's clock is dead without that. Both
transports implement this; an upload gauged on one side but not the
other is a parity bug. Default: nothing to gauge.
Source Code
def uplink_session_conns(self) -> List[Tuple[Any, Optional[str], Optional[str]]]:
"""``(websocket, session token, peer ip)`` per connected client
session, for upload uplink gauging (`UplinkGauge`).
The websocket must send ``ping()`` frames, and the service's message
loop must run with autoping off, answer PING itself, and hand every
PONG to `note_pong` — the gauge's clock is dead without that. Both
transports implement this; an upload gauged on one side but not the
other is a parity bug. Default: nothing to gauge.
"""
return []Returns
typing.List[typing.Tuple[typing.Any, typing.Optional[str], typing.Optional[str]]]