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.
|
|
|
|
import 'package:get_it/get_it.dart';
|
|
|
|
|
import 'package:test_sa/modules/cx_module/chat/services/signalr_service.dart';
|
|
|
|
|
import 'package:test_sa/modules/cx_module/chat/call/services/webrtc_service.dart';
|
|
|
|
|
|
|
|
|
|
/// Global service locator instance
|
|
|
|
|
final getIt = GetIt.instance;
|
|
|
|
|
|
|
|
|
|
/// Setup dependency injection
|
|
|
|
|
Future<void> setupServiceLocator() async {
|
|
|
|
|
// SignalR Service - ONLY ONE instance for the entire app
|
|
|
|
|
getIt.registerLazySingleton<SignalRService>(
|
|
|
|
|
() => SignalRService(),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// WebRTC Service - ONLY ONE instance for the entire app
|
|
|
|
|
getIt.registerLazySingleton<WebRTCService>(
|
|
|
|
|
() => WebRTCService(),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
print('✅ [DI] Service locator initialized');
|
|
|
|
|
print(' - SignalRService registered as singleton (hashCode: ${getIt<SignalRService>().hashCode})');
|
|
|
|
|
print(' - WebRTCService registered as singleton (hashCode: ${getIt<WebRTCService>().hashCode})');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> resetServices() async {
|
|
|
|
|
await getIt<SignalRService>().reset();
|
|
|
|
|
print('✅ [DI] All services reset');
|
|
|
|
|
}
|