mirror of
				https://gitlab.com/comunic/comunicmobile
				synced 2025-11-03 19:54:12 +00:00 
			
		
		
		
	Can join & leave the call
This commit is contained in:
		
							
								
								
									
										15
									
								
								lib/helpers/calls_helper.dart
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								lib/helpers/calls_helper.dart
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,15 @@
 | 
				
			|||||||
 | 
					import 'package:comunic/helpers/websocket_helper.dart';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/// Calls helper
 | 
				
			||||||
 | 
					///
 | 
				
			||||||
 | 
					/// @author Pierre Hubert
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class CallsHelper {
 | 
				
			||||||
 | 
					  /// Join a call
 | 
				
			||||||
 | 
					  static Future<void> join(int convID) async =>
 | 
				
			||||||
 | 
					      ws("calls/join", {"convID": convID});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /// Leave a call
 | 
				
			||||||
 | 
					  static Future<void> leave(int convID) async =>
 | 
				
			||||||
 | 
					      ws("calls/leave", {"convID": convID});
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -1,3 +1,4 @@
 | 
				
			|||||||
 | 
					import 'package:comunic/helpers/calls_helper.dart';
 | 
				
			||||||
import 'package:comunic/helpers/conversations_helper.dart';
 | 
					import 'package:comunic/helpers/conversations_helper.dart';
 | 
				
			||||||
import 'package:comunic/models/conversation.dart';
 | 
					import 'package:comunic/models/conversation.dart';
 | 
				
			||||||
import 'package:comunic/ui/widgets/comunic_back_button_widget.dart';
 | 
					import 'package:comunic/ui/widgets/comunic_back_button_widget.dart';
 | 
				
			||||||
@@ -54,13 +55,23 @@ class _CallScreenState extends SafeState<CallScreen> {
 | 
				
			|||||||
      assert(_convName != null);
 | 
					      assert(_convName != null);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      setState(() {});
 | 
					      setState(() {});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      // Join the call
 | 
				
			||||||
 | 
					      await CallsHelper.join(convID);
 | 
				
			||||||
    } catch (e, stack) {
 | 
					    } catch (e, stack) {
 | 
				
			||||||
      print("Could not initialize call! $e\n$stack");
 | 
					      print("Could not initialize call! $e\n$stack");
 | 
				
			||||||
      setState(() => _error = true);
 | 
					      setState(() => _error = true);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  void _endCall() async {}
 | 
					  void _endCall() async {
 | 
				
			||||||
 | 
					    try {
 | 
				
			||||||
 | 
					      // Leave the call
 | 
				
			||||||
 | 
					      await CallsHelper.leave(convID);
 | 
				
			||||||
 | 
					    } catch (e, stack) {
 | 
				
			||||||
 | 
					      print("Could not end call properly! $e\n$stack");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @override
 | 
					  @override
 | 
				
			||||||
  Widget build(BuildContext context) {
 | 
					  Widget build(BuildContext context) {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user