Add SSE second-level dashboard stream and 2s client heartbeat.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-10-17 21:04:55 +08:00
parent ba74a9cce8
commit d860156b11
8 changed files with 114 additions and 62 deletions
+6 -7
View File
@@ -1447,23 +1447,22 @@ class OrderApp(tk.Tk):
self._run_async(work)
def _hub_heartbeat(self) -> None:
"""定期 ping 中控,供网页显示在线;断线则提示(不允许离线运行)。"""
"""约每 2 秒 ping 中控,供总览秒级在线状态。"""
interval_ms = 2000
if hub_client is None or not is_activated():
self.after(60000, self._hub_heartbeat)
self.after(interval_ms, self._hub_heartbeat)
return
def work():
ok = False
try:
ok = bool(hub_client.ping())
return bool(hub_client.ping())
except Exception:
ok = False
return ok
return False
def done(ok: bool):
if not ok:
self.set_status("中控离线:请检查服务器,客户端需保持在线", ok=False)
self.after(60000, self._hub_heartbeat)
self.after(interval_ms, self._hub_heartbeat)
def run():
ok = work()