You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
cloudsolutions-atoms/lib/modules/cx_module/chat/call/call_debug_helper.dart

93 lines
4.9 KiB
Dart

import 'dart:developer';
import 'package:flutter/foundation.dart';
/// Helper class to debug call issues
class CallDebugHelper {
static void logCallInitiation({
required String callerEmployeeNumber,
required String calleeEmployeeNumber,
required bool isVideo,
required String hubConnectionState,
}) {
log('═══════════════════════════════════════════', name: 'CALL_DEBUG');
log('📞 INITIATING CALL', name: 'CALL_DEBUG');
log('═══════════════════════════════════════════', name: 'CALL_DEBUG');
log('Caller: $callerEmployeeNumber', name: 'CALL_DEBUG');
log('Callee: $calleeEmployeeNumber', name: 'CALL_DEBUG');
log('Type: ${isVideo ? "VIDEO" : "AUDIO"}', name: 'CALL_DEBUG');
log('Hub State: $hubConnectionState', name: 'CALL_DEBUG');
log('═══════════════════════════════════════════', name: 'CALL_DEBUG');
}
static void logConnectionStatus({
required String employeeNumber,
required bool isConnected,
required bool handlersRegistered,
String? additionalInfo,
}) {
log('═══════════════════════════════════════════', name: 'CALL_DEBUG');
log('📡 CONNECTION STATUS CHECK', name: 'CALL_DEBUG');
log('═══════════════════════════════════════════', name: 'CALL_DEBUG');
log('Employee: $employeeNumber', name: 'CALL_DEBUG');
log('Connected: $isConnected', name: 'CALL_DEBUG');
log('Handlers Registered: $handlersRegistered', name: 'CALL_DEBUG');
if (additionalInfo != null) {
log('Info: $additionalInfo', name: 'CALL_DEBUG');
}
log('═══════════════════════════════════════════', name: 'CALL_DEBUG');
}
static void logEventReceived({
required String eventName,
required dynamic rawData,
required String currentStatus,
}) {
log('═══════════════════════════════════════════', name: 'CALL_DEBUG');
log('📨 SIGNALR EVENT RECEIVED', name: 'CALL_DEBUG');
log('═══════════════════════════════════════════', name: 'CALL_DEBUG');
log('Event: $eventName', name: 'CALL_DEBUG');
log('Current Status: $currentStatus', name: 'CALL_DEBUG');
log('Raw Data: $rawData', name: 'CALL_DEBUG');
log('═══════════════════════════════════════════', name: 'CALL_DEBUG');
}
static void printCallTroubleshooting() {
if (kDebugMode) {
print('\n');
print('╔════════════════════════════════════════════════════════════╗');
print('║ CALL NOT RECEIVED - TROUBLESHOOTING ║');
print('╚════════════════════════════════════════════════════════════╝');
print('');
print('Check the following on BOTH devices:');
print('');
print('1. SignalR Connection:');
print(' Look for: "🔌 SignalR Hub Connection: Started"');
print(' Look for: "✅ All call handlers registered successfully"');
print('');
print('2. Employee Numbers:');
print(' Verify sender and recipient employee numbers are correct');
print(' Look for: "🔵 [CALL] Sender: XXX"');
print(' Look for: " - target: XXX"');
print('');
print('3. Backend Response:');
print(' On receiving device, look for:');
print(' "📞 [CALL EVENT] OnIncomingCallAsync received"');
print('');
print('4. Common Issues:');
print(' ❌ Receiving device not connected to SignalR');
print(' ❌ Call handlers not registered (app not in chat screen)');
print(' ❌ Wrong employee number in backend mapping');
print(' ❌ Backend feature flag disabled for audio/video calls');
print(' ❌ Network connectivity issues');
print('');
print('5. Backend Logs:');
print(' Check backend logs for CallUserAsync invocation');
print(' Verify backend is routing to correct user connection');
print('');
print('╚════════════════════════════════════════════════════════════╝');
print('\n');
}
}
}