21 lines
414 B
Python
21 lines
414 B
Python
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)
|