-
Notifications
You must be signed in to change notification settings - Fork 0
Add signal r #66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add signal r #66
Changes from all commits
d103622
a8f0ffa
85c7c8a
83a0d0c
619a531
8c024d5
d240d84
f615112
90a1570
efb1ddb
80a810e
1a2605a
9029eea
5734dc6
0cfa247
d683a96
b7a4564
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -36,12 +36,17 @@ | |||||||||||||||||||||||
| }); | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| builder.Services.AddSignalR(); | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| builder.Services.AddSignalR(); | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| var app = builder.Build(); | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| app.MapHub<DetectedDeviceHub>("/hubs/detecteddevices"); | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| app.MapHub<DetectedDeviceHub>("/hubs/detecteddevices"); | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
Comment on lines
+41
to
+49
|
||||||||||||||||||||||||
| builder.Services.AddSignalR(); | |
| var app = builder.Build(); | |
| app.MapHub<DetectedDeviceHub>("/hubs/detecteddevices"); | |
| app.MapHub<DetectedDeviceHub>("/hubs/detecteddevices"); | |
| var app = builder.Build(); | |
| app.MapHub<DetectedDeviceHub>("/hubs/detecteddevices"); |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -18,12 +18,13 @@ class _CanteenPageState extends State<CanteenPage> { | |||||
| HubConnection? _hubConnection; | ||||||
| // Track when the image was last updated | ||||||
| DateTime? _lastUpdated; | ||||||
| final GlobalKey _futureBuilderKey = GlobalKey(); | ||||||
| bool _needsRefresh = false; | ||||||
| Image? _lastImage; | ||||||
|
|
||||||
| @override | ||||||
| void initState() { | ||||||
| super.initState(); | ||||||
| _needsRefresh = true; // Ensure image loads on first open | ||||||
| _initSignalR(); | ||||||
| } | ||||||
|
|
||||||
|
|
@@ -36,8 +37,6 @@ class _CanteenPageState extends State<CanteenPage> { | |||||
| '$backendUrl/hubs/detecteddevices', | ||||||
| HttpConnectionOptions( | ||||||
| logging: (level, message) => print('SignalR $level: $message'), | ||||||
| skipNegotiation: true, | ||||||
| transport: HttpTransportType.webSockets, | ||||||
| ), | ||||||
| ) | ||||||
| .withAutomaticReconnect() | ||||||
|
|
@@ -57,13 +56,16 @@ class _CanteenPageState extends State<CanteenPage> { | |||||
| } | ||||||
| }); | ||||||
| }); | ||||||
| _hubConnection?.on('NewDevicesDetected', (arguments) { | ||||||
| print('Received NewDevicesDetected: $arguments'); | ||||||
| _hubConnection?.on('NewDevicesDetected', (arguments) async { | ||||||
| print('SignalR: NewDevicesDetected event received!'); | ||||||
| print('Jeg bliver ikke mounted'); | ||||||
|
||||||
| print('Jeg bliver ikke mounted'); | |
| log('SignalR: Component not mounted during NewDevicesDetected event.', name: 'CanteenPage'); |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import 'package:flutter_test/flutter_test.dart'; | ||
| import 'package:crowdedapp/canteen_pages.dart'; | ||
| import 'package:flutter/material.dart'; | ||
|
|
||
| void main() { | ||
| testWidgets('CanteenPage renders without crashing', (WidgetTester tester) async { | ||
| await tester.runAsync(() async { | ||
| await tester.pumpWidget(const MaterialApp(home: CanteenPage(title: 'Canteen View'))); | ||
| // Wait for any pending timers to complete (simulate enough time for all timers) | ||
| await Future.delayed(const Duration(seconds: 6)); | ||
| await tester.pumpAndSettle(); | ||
| // Just check that the widget tree contains CanteenPage | ||
| expect(find.byType(CanteenPage), findsOneWidget); | ||
| }); | ||
| }); | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -4,16 +4,18 @@ import 'package:flutter/material.dart'; | |||||
|
|
||||||
| void main() { | ||||||
| testWidgets('Bottom navigation switches pages', (WidgetTester tester) async { | ||||||
| await tester.pumpWidget(const Crowdedapp()); | ||||||
| await tester.runAsync(() async { | ||||||
| await tester.pumpWidget(const Crowdedapp()); | ||||||
|
|
||||||
| // Home page should be visible | ||||||
| expect(find.text('Welcome to Horizon'), findsOneWidget); | ||||||
| // Home page should be visible | ||||||
| expect(find.text('Welcome to Horizon'), findsOneWidget); | ||||||
|
|
||||||
| // Tap the Canteen tab | ||||||
| await tester.tap(find.byIcon(Icons.restaurant)); | ||||||
| await tester.pumpAndSettle(); | ||||||
| // Tap the Canteen tab | ||||||
| await tester.tap(find.byIcon(Icons.restaurant)); | ||||||
| await tester.pump(const Duration(seconds: 1)); // Use a fixed pump duration instead of pumpAndSettle | ||||||
|
||||||
| await tester.pump(const Duration(seconds: 1)); // Use a fixed pump duration instead of pumpAndSettle | |
| await tester.pumpAndSettle(); // Dynamically wait for all animations and transitions to complete |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicate registration of SignalR services detected. Ensure that SignalR is only added once to avoid potential conflicts or unexpected behavior.