From c7ee7f3c8ffa67e05528b3d254fa98eaef704828 Mon Sep 17 00:00:00 2001 From: cort Date: Fri, 3 Oct 2025 08:01:42 -0500 Subject: [PATCH] Fix startup errors: complete method renaming and restore corrupted file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fixed _send_forwarding_stats() method (was still named _broadcast_forwarding_stats) - Updated stats emission to use active_calls/total_calls_today - Restored dashboard/server.py from corruption (bad replacement) - Properly implemented all send_to_clients renamings - Added forwarding_stats event handler to dashboard - Both services now start successfully Services tested and working: ✅ run.py starts without errors ✅ run_dashboard.py starts without errors --- dashboard/server.py | 17 +++++------------ hblink4/hblink.py | 8 ++++---- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/dashboard/server.py b/dashboard/server.py index f7acf66..417be55 100644 --- a/dashboard/server.py +++ b/dashboard/server.py @@ -1,18 +1,12 @@ """ HBlink4 Dashboard - Separate Process -FastAPI + Uvicorn + WebSockets for re self.stats['total_streams_today'] = 0 - self.stats['total_duration_today'] = 0 - self.stats['total_calls_today'] = 0ime monitoring +FastAPI + Uvicorn + WebSockets for real-time monitoring Updates every 10 superframes (60 packets = 1 second) for smooth real-time feel """ import asyncio import json -from d # Send to all WebSocket clients - await self.send_to_clients(event) - - async def send_to_clients(self, event: dict): - """Send event to all connected WebSocket clients"""me import datetime, date +from datetime import datetime, date from collections import deque from typing import Dict, List, Set, Optional from fastapi import FastAPI, WebSocket, WebSocketDisconnect @@ -74,8 +68,8 @@ class DashboardState: self.stats = { 'total_streams_today': 0, 'total_duration_today': 0.0, # Total duration in seconds - 'packets_forwarded': 0, # Total packets forwarded - 'packets_received': 0, # Total packets received + 'active_calls': 0, # Currently active forwarded calls + 'total_calls_today': 0, # Total calls forwarded today 'start_time': datetime.now().isoformat(), 'last_reset_date': date.today().isoformat() # Track when stats were last reset } @@ -84,8 +78,7 @@ class DashboardState: """Reset daily statistics at midnight""" self.stats['total_streams_today'] = 0 self.stats['total_duration_today'] = 0.0 - self.stats['packets_forwarded'] = 0 - self.stats['packets_received'] = 0 + self.stats['total_calls_today'] = 0 self.stats['last_reset_date'] = date.today().isoformat() logger.info(f"📊 Daily stats reset at midnight (server time)") diff --git a/hblink4/hblink.py b/hblink4/hblink.py index 6b85fc3..2f3104c 100644 --- a/hblink4/hblink.py +++ b/hblink4/hblink.py @@ -710,11 +710,11 @@ class HBProtocol(DatagramProtocol): 'stats': stats }) - def _broadcast_forwarding_stats(self): - """Broadcast forwarding statistics to dashboard""" + def _send_forwarding_stats(self): + """Send forwarding statistics to dashboard""" self._events.emit('forwarding_stats', { - 'packets_forwarded': self._forwarding_stats['packets_forwarded'], - 'packets_received': self._forwarding_stats['packets_received'], + 'active_calls': self._forwarding_stats['active_calls'], + 'total_calls_today': self._forwarding_stats['total_calls_today'], 'uptime_seconds': time() - self._forwarding_stats['start_time'] })