from backend.events.bus import EventBus import json class WebSocketStream: def __init__(self): self.clients = [] def attach_bus(self, bus: EventBus): def forward(event): payload = json.dumps(event) for c in self.clients: c.send(payload) bus.subscribe(forward) def register_client(self, client): self.clients.append(client)