mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-12-26 04:48:51 +00:00
Handle call closed event
This commit is contained in:
parent
08d357fc72
commit
456df166b1
@ -86,6 +86,13 @@ class UserLeftCallEvent {
|
||||
UserLeftCallEvent(this.callID, this.userID);
|
||||
}
|
||||
|
||||
/// Call closed event
|
||||
class CallClosedEvent {
|
||||
final int callID;
|
||||
|
||||
CallClosedEvent(this.callID);
|
||||
}
|
||||
|
||||
class EventsHelper {
|
||||
static EventBus _mgr = EventBus();
|
||||
|
||||
|
@ -173,6 +173,11 @@ class WebSocketHelper {
|
||||
UserLeftCallEvent(msg.data["callID"], msg.data["userID"]));
|
||||
break;
|
||||
|
||||
// The call has been close
|
||||
case "call_closed":
|
||||
EventsHelper.emit(CallClosedEvent(msg.data));
|
||||
break;
|
||||
|
||||
default:
|
||||
throw Exception("Unknown message type: ${msg.title}");
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import 'package:comunic/lists/users_list.dart';
|
||||
import 'package:comunic/models/call_config.dart';
|
||||
import 'package:comunic/models/call_member.dart';
|
||||
import 'package:comunic/models/conversation.dart';
|
||||
import 'package:comunic/ui/routes/main_route.dart';
|
||||
import 'package:comunic/ui/widgets/comunic_back_button_widget.dart';
|
||||
import 'package:comunic/ui/widgets/safe_state.dart';
|
||||
import 'package:comunic/utils/account_utils.dart';
|
||||
@ -88,12 +89,17 @@ class _CallScreenState extends SafeState<CallScreen> {
|
||||
this.listen<UserLeftCallEvent>((e) {
|
||||
if (e.callID == convID) _removeMember(e.userID);
|
||||
});
|
||||
|
||||
this.listen<CallClosedEvent>((e) {
|
||||
if (e.callID == convID) _leaveCall();
|
||||
});
|
||||
} catch (e, stack) {
|
||||
print("Could not initialize call! $e\n$stack");
|
||||
setState(() => _error = true);
|
||||
}
|
||||
}
|
||||
|
||||
// Do clean up operations when call screen is destroyed
|
||||
void _endCall() async {
|
||||
try {
|
||||
// Leave the call
|
||||
@ -103,6 +109,11 @@ class _CallScreenState extends SafeState<CallScreen> {
|
||||
}
|
||||
}
|
||||
|
||||
// Make us leave the call
|
||||
void _leaveCall() {
|
||||
MainController.of(context).popPage();
|
||||
}
|
||||
|
||||
void _removeMember(int memberID) {
|
||||
_membersList.removeUser(memberID);
|
||||
setState(() {});
|
||||
|
Loading…
Reference in New Issue
Block a user