Reduce debug message that were flooding the bus

parent 1e837e54
...@@ -3215,19 +3215,12 @@ class QtVideoPlayer(QObject): ...@@ -3215,19 +3215,12 @@ class QtVideoPlayer(QObject):
def _on_position_changed(self, position: int, duration: int): def _on_position_changed(self, position: int, duration: int):
"""Handle position changes from player window""" """Handle position changes from player window"""
try: try:
# Send progress update via message bus # Progress updates are now handled by the throttled periodic _send_progress_update method
if duration > 0: # to prevent flooding the message bus with VIDEO_PROGRESS messages
percentage = (position / duration) * 100 pass
progress_message = MessageBuilder.video_progress(
sender=self.name,
position=position / 1000.0, # Convert to seconds
duration=duration / 1000.0, # Convert to seconds
percentage=percentage
)
self.message_bus.publish(progress_message, broadcast=True)
except Exception as e: except Exception as e:
logger.error(f"Failed to send progress update: {e}") logger.error(f"Failed to handle position change: {e}")
def _on_video_loaded(self, file_path: str): def _on_video_loaded(self, file_path: str):
"""Handle video loaded event""" """Handle video loaded event"""
......
...@@ -814,8 +814,6 @@ ...@@ -814,8 +814,6 @@
}, 5000); }, 5000);
})(); })();
// Test console override
console.log('TEST: Console override applied and buffering');
// Debug timing helper // Debug timing helper
function getTimestamp() { function getTimestamp() {
...@@ -838,66 +836,49 @@ ...@@ -838,66 +836,49 @@
// Check if WebChannel is available // Check if WebChannel is available
if (!window.overlay || typeof window.overlay.getCurrentData !== 'function') { if (!window.overlay || typeof window.overlay.getCurrentData !== 'function') {
console.log('DEBUG: WebChannel not ready, retrying...');
if (retryCount < maxRetries) { if (retryCount < maxRetries) {
const delay = baseDelay * Math.pow(2, retryCount); const delay = baseDelay * Math.pow(2, retryCount);
console.log(`DEBUG: Retrying in ${delay}ms (attempt ${retryCount + 1}/${maxRetries + 1})`);
setTimeout(() => { setTimeout(() => {
fetchResultsData(retryCount + 1); fetchResultsData(retryCount + 1);
}, delay); }, delay);
} else { } else {
console.log('DEBUG: Max retries reached, using fallback data');
debugTime('Max retries reached for WebChannel connection'); debugTime('Max retries reached for WebChannel connection');
showFallbackResults(); showFallbackResults();
} }
return; return;
} }
console.log('DEBUG: WebChannel available, calling getCurrentData()');
// Call WebChannel method to get current overlay data // Call WebChannel method to get current overlay data
const currentDataJson = await window.overlay.getCurrentData(); const currentDataJson = await window.overlay.getCurrentData();
console.log('DEBUG: WebChannel response received');
console.log('DEBUG: Raw response =', currentDataJson);
let data; let data;
try { try {
data = JSON.parse(currentDataJson); data = JSON.parse(currentDataJson);
console.log('DEBUG: WebChannel response JSON parsed successfully');
console.log('DEBUG: WebChannel response data =', data);
} catch (parseError) { } catch (parseError) {
console.log('DEBUG: Failed to parse WebChannel response as JSON');
throw new Error(`JSON parse error: ${parseError.message}`); throw new Error(`JSON parse error: ${parseError.message}`);
} }
debugTime('Results data received via WebChannel'); debugTime('Results data received via WebChannel');
if (data && (data.outcome || data.result)) { if (data && (data.outcome || data.result)) {
console.log('DEBUG: WebChannel returned results data');
updateOverlayData(data); updateOverlayData(data);
} else { } else {
console.log('DEBUG: WebChannel response did not contain results data');
debugTime('No results data in WebChannel response'); debugTime('No results data in WebChannel response');
// Keep checking for data // Keep checking for data
setTimeout(() => fetchResultsData(0), 1000); setTimeout(() => fetchResultsData(0), 1000);
} }
} catch (error) { } catch (error) {
console.log('DEBUG: Exception caught in fetchResultsData');
console.log('DEBUG: Error message =', error.message);
console.log('DEBUG: Error stack =', error.stack);
debugTime(`Failed to fetch results data: ${error.message}`); debugTime(`Failed to fetch results data: ${error.message}`);
// Check if we should retry // Check if we should retry
if (retryCount < maxRetries) { if (retryCount < maxRetries) {
// Calculate delay with exponential backoff // Calculate delay with exponential backoff
const delay = baseDelay * Math.pow(2, retryCount); const delay = baseDelay * Math.pow(2, retryCount);
console.log(`DEBUG: Retrying in ${delay}ms (attempt ${retryCount + 2}/${maxRetries + 1})`);
setTimeout(() => { setTimeout(() => {
fetchResultsData(retryCount + 1); fetchResultsData(retryCount + 1);
}, delay); }, delay);
} else { } else {
console.log('DEBUG: Max retries reached, using fallback data');
debugTime('Max retries reached for results data fetch'); debugTime('Max retries reached for results data fetch');
// Show fallback data instead of error message // Show fallback data instead of error message
showFallbackResults(); showFallbackResults();
...@@ -922,9 +903,6 @@ ...@@ -922,9 +903,6 @@
// Fallback to console if WebChannel not available - use original console to avoid recursion // Fallback to console if WebChannel not available - use original console to avoid recursion
originalConsoleLog(`[RESULTS FALLBACK] ${message}`); originalConsoleLog(`[RESULTS FALLBACK] ${message}`);
} }
// Always log to console as well for browser debugging - use original to avoid recursion
originalConsoleLog(`🔍 DEBUG: ${message}`);
} }
// Store original console.log before overriding // Store original console.log before overriding
...@@ -934,17 +912,9 @@ ...@@ -934,17 +912,9 @@
function setupWebChannel() { function setupWebChannel() {
// Check if WebChannel is already set up by overlay.js // Check if WebChannel is already set up by overlay.js
if (window.overlay) { if (window.overlay) {
console.log('🔍 DEBUG: WebChannel already set up by overlay.js');
// Test WebChannel
if (window.overlay && window.overlay.log) {
window.overlay.log('TEST: WebChannel connection successful');
}
// Listen for data updates from Python // Listen for data updates from Python
if (window.overlay.dataUpdated) { if (window.overlay.dataUpdated) {
window.overlay.dataUpdated.connect(function(data) { window.overlay.dataUpdated.connect(function(data) {
console.log('🔍 DEBUG: Received data update from Python:', data);
if (data && (data.outcome || data.result)) { if (data && (data.outcome || data.result)) {
updateOverlayData(data); updateOverlayData(data);
} }
...@@ -968,15 +938,12 @@ ...@@ -968,15 +938,12 @@
if (typeof qt !== 'undefined' && qt.webChannelTransport) { if (typeof qt !== 'undefined' && qt.webChannelTransport) {
try { try {
new QWebChannel(qt.webChannelTransport, function(channel) { new QWebChannel(qt.webChannelTransport, function(channel) {
console.log('🔍 DEBUG: WebChannel connected successfully (fallback)');
// Connect to overlay object // Connect to overlay object
window.overlay = channel.objects.overlay; window.overlay = channel.objects.overlay;
// Listen for data updates from Python // Listen for data updates from Python
if (window.overlay && window.overlay.dataUpdated) { if (window.overlay && window.overlay.dataUpdated) {
window.overlay.dataUpdated.connect(function(data) { window.overlay.dataUpdated.connect(function(data) {
console.log('🔍 DEBUG: Received data update from Python:', data);
if (data && (data.outcome || data.result)) { if (data && (data.outcome || data.result)) {
updateOverlayData(data); updateOverlayData(data);
} }
...@@ -993,13 +960,9 @@ ...@@ -993,13 +960,9 @@
} }
webChannelReady = true; webChannelReady = true;
console.log('🔍 DEBUG: WebChannel ready for results data');
}); });
} catch (e) { } catch (e) {
console.log('🔍 DEBUG: Failed to setup WebChannel:', e);
} }
} else {
console.log('🔍 DEBUG: WebChannel not available, will retry');
} }
} }
...@@ -1007,7 +970,6 @@ ...@@ -1007,7 +970,6 @@
// Show fallback results data when API is not available yet // Show fallback results data when API is not available yet
function showFallbackResults() { function showFallbackResults() {
console.log('🔍 DEBUG: Showing fallback results data - API not available yet');
const fallbackData = { const fallbackData = {
outcome: 'WIN1', outcome: 'WIN1',
under_over_result: 'OVER', under_over_result: 'OVER',
...@@ -1017,7 +979,6 @@ ...@@ -1017,7 +979,6 @@
}, },
match_id: 1 match_id: 1
}; };
console.log('🔍 DEBUG: Fallback results data loaded, processing');
updateOverlayData(fallbackData); updateOverlayData(fallbackData);
} }
...@@ -1040,7 +1001,6 @@ ...@@ -1040,7 +1001,6 @@
// Function to update overlay data (called by Qt WebChannel) // Function to update overlay data (called by Qt WebChannel)
function updateOverlayData(data) { function updateOverlayData(data) {
console.log('RESULTS TEMPLATE: updateOverlayData called with data:', data);
overlayData = data || {}; overlayData = data || {};
// Only update if we have valid data // Only update if we have valid data
...@@ -1051,7 +1011,6 @@ ...@@ -1051,7 +1011,6 @@
// Check if this is the same data we already processed (prevent duplicate processing) // Check if this is the same data we already processed (prevent duplicate processing)
const dataHash = JSON.stringify(data); const dataHash = JSON.stringify(data);
if (window.lastProcessedDataHash === dataHash) { if (window.lastProcessedDataHash === dataHash) {
console.log('RESULTS TEMPLATE: Duplicate data received, ignoring');
return; return;
} }
window.lastProcessedDataHash = dataHash; window.lastProcessedDataHash = dataHash;
...@@ -1062,7 +1021,6 @@ ...@@ -1062,7 +1021,6 @@
// Check if under/over result is provided separately // Check if under/over result is provided separately
if (data.under_over_result) { if (data.under_over_result) {
currentUnderOverResult = data.under_over_result; currentUnderOverResult = data.under_over_result;
console.log('RESULTS TEMPLATE: Under/over result provided separately:', currentUnderOverResult);
} else { } else {
// Fallback: determine if main result is under/over // Fallback: determine if main result is under/over
if (result === 'UNDER' || result === 'OVER') { if (result === 'UNDER' || result === 'OVER') {
...@@ -1075,20 +1033,16 @@ ...@@ -1075,20 +1033,16 @@
if (data.match) { if (data.match) {
currentMatch = data.match; currentMatch = data.match;
console.log('RESULTS TEMPLATE: Match data received:', data.match);
} }
if (data.match_id) { if (data.match_id) {
console.log('RESULTS TEMPLATE: Match ID received:', data.match_id);
// Fetch winning outcomes for this match // Fetch winning outcomes for this match
fetchWinningOutcomes(data.match_id); fetchWinningOutcomes(data.match_id);
// Check if results have already been shown for this match (handles overlay reloads) // Check if results have already been shown for this match (handles overlay reloads)
const resultsShownKey = 'results_shown_' + data.match_id; const resultsShownKey = 'results_shown_' + data.match_id;
const alreadyShown = sessionStorage.getItem(resultsShownKey) === 'true'; const alreadyShown = sessionStorage.getItem(resultsShownKey) === 'true';
console.log('RESULTS TEMPLATE: Results already shown for match?', alreadyShown);
if (alreadyShown) { if (alreadyShown) {
console.log('RESULTS TEMPLATE: Results already shown for this match, displaying immediately');
contentVisible = true; contentVisible = true;
showResultsPanel(); showResultsPanel();
showResultsContent(); showResultsContent();
...@@ -1097,11 +1051,9 @@ ...@@ -1097,11 +1051,9 @@
} }
// Prepare data and start 5-second timer to show results // Prepare data and start 5-second timer to show results
console.log('RESULTS TEMPLATE: Results data received, preparing animation data');
prepareResultsAnimation(); prepareResultsAnimation();
} else { } else {
console.log('RESULTS TEMPLATE: No valid data received, will retry fetching');
// Keep trying to fetch data // Keep trying to fetch data
setTimeout(() => fetchResultsData(0), 1000); setTimeout(() => fetchResultsData(0), 1000);
} }
...@@ -1124,8 +1076,6 @@ ...@@ -1124,8 +1076,6 @@
// Show blue background after 5 seconds from data receipt // Show blue background after 5 seconds from data receipt
setTimeout(() => { setTimeout(() => {
if (!contentVisible) { if (!contentVisible) {
console.log('RESULTS TEMPLATE: Showing blue background after 5 seconds from data received');
// Mark results as shown in sessionStorage // Mark results as shown in sessionStorage
if (overlayData && overlayData.match_id) { if (overlayData && overlayData.match_id) {
sessionStorage.setItem('results_shown_' + overlayData.match_id, 'true'); sessionStorage.setItem('results_shown_' + overlayData.match_id, 'true');
...@@ -1136,7 +1086,6 @@ ...@@ -1136,7 +1086,6 @@
// Show data immediately after background appears // Show data immediately after background appears
setTimeout(() => { setTimeout(() => {
contentVisible = true; contentVisible = true;
console.log('RESULTS TEMPLATE: Showing data immediately after background');
showResultsContent(); showResultsContent();
}, 100); // Small delay to ensure background is visible first }, 100); // Small delay to ensure background is visible first
} }
...@@ -1145,19 +1094,14 @@ ...@@ -1145,19 +1094,14 @@
// Fetch winning outcomes for the match // Fetch winning outcomes for the match
function fetchWinningOutcomes(matchId) { function fetchWinningOutcomes(matchId) {
console.log('RESULTS TEMPLATE: fetchWinningOutcomes called for match:', matchId);
// Use Qt WebChannel to request winning outcomes data // Use Qt WebChannel to request winning outcomes data
if (window.overlay && window.overlay.getWinningOutcomes) { if (window.overlay && window.overlay.getWinningOutcomes) {
console.log('RESULTS TEMPLATE: Qt WebChannel available, requesting winning outcomes');
try { try {
const outcomesJson = window.overlay.getWinningOutcomes(matchId); const outcomesJson = window.overlay.getWinningOutcomes(matchId);
const outcomesData = JSON.parse(outcomesJson); const outcomesData = JSON.parse(outcomesJson);
console.log('RESULTS TEMPLATE: Received winning outcomes:', outcomesData);
winningOutcomes = outcomesData || []; winningOutcomes = outcomesData || [];
updateWinningBetsDisplay(); updateWinningBetsDisplay();
} catch (error) { } catch (error) {
console.error('RESULTS TEMPLATE: Failed to get winning outcomes:', error);
// Fallback: show sample data for testing // Fallback: show sample data for testing
winningOutcomes = [ winningOutcomes = [
{ outcome: 'WIN1', amount: 125.00 }, { outcome: 'WIN1', amount: 125.00 },
...@@ -1167,7 +1111,6 @@ ...@@ -1167,7 +1111,6 @@
updateWinningBetsDisplay(); updateWinningBetsDisplay();
} }
} else { } else {
console.warn('RESULTS TEMPLATE: Qt WebChannel not available for fetching winning outcomes');
// Fallback: show sample data for testing // Fallback: show sample data for testing
winningOutcomes = [ winningOutcomes = [
{ outcome: 'WIN1', amount: 125.00 }, { outcome: 'WIN1', amount: 125.00 },
...@@ -1180,25 +1123,17 @@ ...@@ -1180,25 +1123,17 @@
// Show results panel with fade-in animation // Show results panel with fade-in animation
function showResultsPanel() { function showResultsPanel() {
console.log('RESULTS TEMPLATE: showResultsPanel called');
const resultsPanel = document.getElementById('resultsPanel'); const resultsPanel = document.getElementById('resultsPanel');
if (resultsPanel) { if (resultsPanel) {
console.log('RESULTS TEMPLATE: Adding visible class to results panel');
resultsPanel.classList.add('visible'); resultsPanel.classList.add('visible');
} else {
console.log('RESULTS TEMPLATE: ERROR - resultsPanel element not found');
} }
} }
// Show results content with animation after delay // Show results content with animation after delay
function showResultsContent() { function showResultsContent() {
console.log('RESULTS TEMPLATE: showResultsContent called');
const resultsContent = document.getElementById('resultsContent'); const resultsContent = document.getElementById('resultsContent');
if (resultsContent) { if (resultsContent) {
console.log('RESULTS TEMPLATE: Adding visible class to results content');
resultsContent.classList.add('visible'); resultsContent.classList.add('visible');
} else {
console.log('RESULTS TEMPLATE: ERROR - resultsContent element not found');
} }
} }
...@@ -1209,12 +1144,10 @@ ...@@ -1209,12 +1144,10 @@
// Check if video has started playing (position > 0) // Check if video has started playing (position > 0)
if (position > 0 && !videoStarted) { if (position > 0 && !videoStarted) {
videoStarted = true; videoStarted = true;
console.log('RESULTS TEMPLATE: Video started playing at position:', position);
} }
// Check if we've reached 5 seconds and should show results // Check if we've reached 5 seconds and should show results
if (position >= 5 && !contentVisible && overlayData && (overlayData.outcome || overlayData.result)) { if (position >= 5 && !contentVisible && overlayData && (overlayData.outcome || overlayData.result)) {
console.log('RESULTS TEMPLATE: Video reached 5 seconds, showing results');
contentVisible = true; contentVisible = true;
showResultsPanel(); showResultsPanel();
showResultsContent(); showResultsContent();
...@@ -1222,7 +1155,6 @@ ...@@ -1222,7 +1155,6 @@
// Throttle position logging to reduce message bus traffic // Throttle position logging to reduce message bus traffic
if (currentTime - lastPositionLogTime >= POSITION_LOG_THROTTLE_MS) { if (currentTime - lastPositionLogTime >= POSITION_LOG_THROTTLE_MS) {
console.log('RESULTS TEMPLATE: Video position:', position, 'duration:', duration);
lastPositionLogTime = currentTime; lastPositionLogTime = currentTime;
} }
} }
...@@ -1340,19 +1272,15 @@ ...@@ -1340,19 +1272,15 @@
setupWebChannel(); setupWebChannel();
// Show initial state // Show initial state
console.log('RESULTS TEMPLATE: DOM loaded, starting data fetch');
// Wait briefly for WebChannel to connect // Wait briefly for WebChannel to connect
setTimeout(() => { setTimeout(() => {
console.log('🔍 DEBUG: Starting results data fetch via WebChannel');
// Fetch results data via WebChannel // Fetch results data via WebChannel
debugTime('Fetching results data via WebChannel'); debugTime('Fetching results data via WebChannel');
fetchResultsData(); fetchResultsData();
// Set up periodic refresh every 30 seconds // Set up periodic refresh every 30 seconds
setInterval(() => { setInterval(() => {
debugTime('Periodic refresh: fetching updated results data');
fetchResultsData(0); // Start with retry count 0 for periodic refreshes fetchResultsData(0); // Start with retry count 0 for periodic refreshes
}, 30000); }, 30000);
...@@ -1361,8 +1289,6 @@ ...@@ -1361,8 +1289,6 @@
if (!contentVisible) { if (!contentVisible) {
debugTime('No data received after 5 seconds - showing fallback'); debugTime('No data received after 5 seconds - showing fallback');
showFallbackResults(); showFallbackResults();
} else {
debugTime('Data was received before 5 second timeout');
} }
}, 5000); }, 5000);
}, 50); // Wait 50ms for WebChannel setup }, 50); // Wait 50ms for WebChannel setup
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment