pybragerone.api.ws¶
WebSocket (Socket.IO) client for BragerOne realtime events.
Classes
|
Protocol for an event dispatcher used by the realtime manager. |
|
Thin Socket.IO wrapper for BragerOne realtime channel. |
- class pybragerone.api.ws.EventDispatcher(*args, **kwargs)[source]¶
Bases:
ProtocolProtocol for an event dispatcher used by the realtime manager.
- class pybragerone.api.ws.RealtimeManager(token: str, *, origin: str = 'https://one.brager.pl', referer: str = 'https://one.brager.pl/', io_base: str = 'https://io.brager.pl', socket_path: str = '/socket.io', namespace: str = '/ws')[source]¶
Bases:
objectThin Socket.IO wrapper for BragerOne realtime channel.
The manager keeps a single AsyncClient connection, exposes the Engine.IO SID and the namespace SID, and forwards selected events to a user-provided callback (
EventHandler). It does not interpret payloads; that is the gateway’s responsibility.Notes
Authentication is provided only via HTTP headers (Bearer token).
We always connect to the :data:`~.constants.WS_NAMESPACE` namespace.
We listen to:
snapshotand the various*:parameters:changeevents.Subscriptions are emitted in a few payload variants (
modules/devids) and optionally includegroup_id.
- add_on_connected(cb: Callable[[], None | Awaitable[None]])[source]¶
Register a callback to be called when the connection is established.
- async connect()[source]¶
Open a Socket.IO connection with appropriate headers and wait for join.
- Return type:
- on_event(handler: EventDispatcher)[source]¶
Register a single event dispatcher (gateway attaches here).
- Return type:
- Parameters:
handler (EventDispatcher)