Spaces:
Sleeping
Sleeping
Create codexmesh_stream.py
Browse files- codexmesh_stream.py +11 -0
codexmesh_stream.py
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import asyncio
|
| 2 |
+
from datetime import datetime
|
| 3 |
+
from ws_router import broadcast
|
| 4 |
+
|
| 5 |
+
async def emit_event(event_type: str, payload: dict):
|
| 6 |
+
event = {
|
| 7 |
+
"type": event_type,
|
| 8 |
+
"time": datetime.utcnow().isoformat(),
|
| 9 |
+
"payload": payload
|
| 10 |
+
}
|
| 11 |
+
await broadcast(event)
|