From 90b0f177af767873db65e27c692f16313f2e020f Mon Sep 17 00:00:00 2001 From: WaseemAbbasi22 <50428976+WaseemAbbasi22@users.noreply.github.com> Date: Mon, 20 Jul 2026 14:36:16 +0300 Subject: [PATCH] restuctured flow --- .../chat/services/signalr_service.dart | 31 ++- pubspec.yaml | 176 ++++++++++++++++++ 2 files changed, 205 insertions(+), 2 deletions(-) diff --git a/lib/modules/cx_module/chat/services/signalr_service.dart b/lib/modules/cx_module/chat/services/signalr_service.dart index 2252dc72..20149861 100644 --- a/lib/modules/cx_module/chat/services/signalr_service.dart +++ b/lib/modules/cx_module/chat/services/signalr_service.dart @@ -95,10 +95,13 @@ class SignalRService { // Create new connection log('🔧 [SIGNALR] Creating new HubConnection...', name: 'SignalRService'); + log(' URL: ${URLs.chatHubUrlChat}', name: 'SignalRService'); final httpOp = HttpConnectionOptions( skipNegotiation: false, logMessageContent: kDebugMode, + transport: HttpTransportType.WebSockets, // Use WebSockets + requestTimeout: 30000, // 30 seconds timeout ); _hubConnection = HubConnectionBuilder() @@ -114,12 +117,34 @@ class SignalRService { // Setup reconnection handlers BEFORE starting connection _setupReconnectionHandlers(); - // Start connection + // Start connection with timeout log('🔌 [SIGNALR] Starting connection...', name: 'SignalRService'); - await _hubConnection!.start(); + + try { + final startFuture = _hubConnection!.start(); + if (startFuture != null) { + await startFuture.timeout( + const Duration(seconds: 30), + onTimeout: () { + throw TimeoutException('SignalR connection timeout after 30 seconds'); + }, + ); + } else { + log('⚠️ [SIGNALR] start() returned null, checking state...', name: 'SignalRService'); + } + } catch (e) { + log('❌ [SIGNALR] Connection start failed: $e', name: 'SignalRService'); + rethrow; + } + + // Verify connection state + if (_hubConnection!.state != HubConnectionState.Connected) { + throw Exception('SignalR failed to connect. State: ${_hubConnection!.state}'); + } log('✅ [SIGNALR] Connection established', name: 'SignalRService'); log(' Connection ID: ${_hubConnection!.connectionId}', name: 'SignalRService'); + log(' Connection State: ${_hubConnection!.state}', name: 'SignalRService'); // Emit connected state _connectionStateController.add(HubConnectionState.Connected); @@ -141,6 +166,8 @@ class SignalRService { } catch (e, stackTrace) { log('❌ [SIGNALR] Error initializing connection: $e', name: 'SignalRService', error: e, stackTrace: stackTrace); + log(' User ID: $userId', name: 'SignalRService'); + log(' URL: ${URLs.chatHubUrlChat}', name: 'SignalRService'); _isInitializing = false; _initializationCompleter?.complete(false); diff --git a/pubspec.yaml b/pubspec.yaml index e69de29b..159eaeaf 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -0,0 +1,176 @@ +name: test_sa +description: medical app to manage medical devices issues + +# The following line prevents the package from being accidentally published to +# pub.dev using `flutter pub publish`. This is preferred for private packages. +publish_to: 'none' # Remove this line if you wish to publish to pub.dev + +# The following defines the version and build number for your application. +# A version number is three numbers separated by dots, like 1.2.43 +# followed by an optional build number separated by a +. +# Both the version and the builder number may be overridden in flutter +# build by specifying --build-name and --build-number, respectively. +# In Android, build-name is used as versionName while build-number used as versionCode. +# Read more about Android versioning at https://developer.android.com/studio/publish/versioning +# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. +# Read more about iOS versioning at +# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html +version: 1.7.8+44 + +environment: + sdk: ">=3.5.0 <4.0.0" + +#localization_dir: assets\translations + +# Dependencies specify other packages that your package needs in order to work. +# To automatically upgrade your package dependencies to the latest versions +# consider running `flutter pub upgrade --major-versions`. Alternatively, +# dependencies can be manually updated by changing the version numbers below to +# the latest version available on pub.dev. To see which dependencies have newer +# versions available, run `flutter pub outdated`. +dependencies: + flutter: + sdk: flutter + flutter_localizations: + sdk: flutter + + # The following adds the Cupertino Icons font to your application. + # Use with the CupertinoIcons class for iOS style icons. + cupertino_icons: ^1.0.5 + font_awesome_flutter: ^10.12.0 + http: ^1.6.0 + get_it: ^9.2.1 + provider: ^6.1.5+1 + shared_preferences: ^2.5.4 + fluttertoast: ^9.0.0 + image_picker: ^1.2.1 + url_launcher: ^6.3.2 + flutter_launcher_icons: ^0.14.4 + package_info_plus: ^8.3.1 + share_plus: ^10.1.4 + flutter_local_notifications: ^17.2.4 + cached_network_image: ^3.4.1 + carousel_slider: ^5.1.2 + intl: ^0.20.2 + nfc_manager: ^4.2.1 + flutter_typeahead: ^5.2.0 + speech_to_text: ^7.3.0 + firebase_core: ^3.15.2 + firebase_messaging: ^15.2.10 + qr_code_scanner_plus: ^2.1.1 + flutter_sound: ^9.30.0 + permission_handler: ^11.4.0 + rive: ^0.14.4 + another_flushbar: ^1.12.32 + pinput: ^6.0.2 + audioplayers: ^6.6.0 + mobile_scanner: ^7.2.0 + + flare_flutter: + git: + url: https://github.com/mbfakourii/Flare-Flutter.git + path: flare_flutter + ref: remove_hashValues + + signature: ^5.5.0 + flutter_svg: ^2.2.3 + file_picker: ^10.3.10 + record_mp3_plus: ^1.4.1 + path_provider: ^2.1.5 + open_file: ^3.5.11 + localization: ^2.1.0 + dotted_border: ^2.1.0 + lottie: ^3.3.2 + shimmer: ^3.0.0 + date_picker_timeline: ^1.2.6 + flutter_advanced_switch: ^3.0.1 + table_calendar: ^3.0.8 + image_cropper: ^8.1.0 + flutter_timezone: ^3.0.1 + device_calendar: ^4.3.3 + pie_chart: ^5.4.0 + + badges: ^3.1.1 + # buttons_tabbar: ^1.1.2 + flutter_custom_month_picker: ^0.1.3 + local_auth: ^2.3.0 + google_api_availability: ^5.0.1 + huawei_push: ^6.14.0+300 + flutter_webrtc: ^1.5.2 + flutter_callkit_incoming: ^3.1.3 + huawei_location: ^6.16.0+300 + geolocator: ^9.0.2 + wifi_iot: ^0.3.19+2 + just_audio: ^0.9.46 + safe_device: ^1.3.8 + toggle_switch: ^2.3.0 + tree_view_flutter: ^1.0.2 + audio_waveforms: ^1.3.0 + signalr_netcore: ^1.4.4 + ellipsized_text: ^2.0.0 + local_auth_darwin: ^1.4.0 + haptic_feedback: ^0.6.4+3 + sn_progress_dialog: ^1.2.0 + + +dev_dependencies: + flutter_test: + sdk: flutter +dependency_overrides: + sqflite_android: 2.4.1 + win32: ^5.5.4 + flutter_lints: ^2.0.0 + +flutter_icons: + ios: true + android: true + image_path_ios: "assets/images/app_logo.jpg" + image_path_android: "assets/images/app_logo.jpg" + +# The following section is specific to Flutter. +flutter: + config: + enable-swift-package-manager: false + # The following line ensures that the Material Icons font is + # included with your application, so that you can use the icons in + # the material Icons class. + generate: true + uses-material-design: true + assets: + - assets/ + - assets/audio/ + - assets/images/ + - assets/images/dashboard/ + - assets/images/wo/ + - assets/lottie/ + - assets/subtitles/ + - assets/rives/ + fonts: + - family: Swiss + fonts: + - asset: assets/fonts/Gotham_Rounded_Light.otf + weight: 300 + - asset: assets/fonts/Gotham_Rounded_Book.otf + weight: 400 + - asset: assets/fonts/Gotham_Rounded_Bold.otf + weight: 700 + - family: Poppins + fonts: + - asset: assets/fonts/poppins/Poppins-Black.ttf + weight: 900 + - asset: assets/fonts/poppins/Poppins-ExtraBold.ttf + weight: 800 + - asset: assets/fonts/poppins/Poppins-Bold.ttf + weight: 700 + - asset: assets/fonts/poppins/Poppins-SemiBold.ttf + weight: 600 + - asset: assets/fonts/poppins/Poppins-Medium.ttf + weight: 500 + - asset: assets/fonts/poppins/Poppins-Regular.ttf + weight: 400 + - asset: assets/fonts/poppins/Poppins-Light.ttf + weight: 300 + - asset: assets/fonts/poppins/Poppins-ExtraLight.ttf + weight: 200 + - asset: assets/fonts/poppins/Poppins-Thin.ttf + weight: 100 \ No newline at end of file