fix: history_ready event — frontend refetch apos replay completo

This commit is contained in:
rufinomec-afk
2026-06-07 23:09:29 -03:00
parent 310c1f52bd
commit c74b411404
3 changed files with 20 additions and 3 deletions
+13 -1
View File
@@ -44,8 +44,20 @@ def broadcast_update(active_json: dict, closed_json: Optional[dict]):
for connection in list(active_connections):
asyncio.create_task(safe_send(connection, message))
def broadcast_history_ready():
"""Notify all clients that historical replay is complete — they should refetch /history."""
if not active_connections:
return
async def _send():
for ws in list(active_connections):
try:
await ws.send_json({"type": "history_ready"})
except Exception:
active_connections.discard(ws)
asyncio.create_task(_send())
# Initialize MT5 Collector
collector = MT5Collector(aggregator, on_update_callback=broadcast_update)
collector = MT5Collector(aggregator, on_update_callback=broadcast_update, on_history_ready_callback=broadcast_history_ready)
async def _start_collector_delayed():
"""Wait a moment for the server to fully start, then begin polling MT5."""