From 9695a5ad1056dd3834193bc16c6fd82f5a39e88f Mon Sep 17 00:00:00 2001 From: cloudwebrtc Date: Mon, 8 Aug 2022 22:50:43 +0800 Subject: [PATCH] chore: Use onRoomState to monitor group call creation and member join and leave. --- lib/src/client.dart | 2 ++ lib/src/room.dart | 2 ++ lib/src/voip/voip.dart | 9 ++++++--- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/src/client.dart b/lib/src/client.dart index c8293c61..1b0a986c 100644 --- a/lib/src/client.dart +++ b/lib/src/client.dart @@ -1098,6 +1098,8 @@ class Client extends MatrixApi { final CachedStreamController onGroupMember = CachedStreamController(); + final CachedStreamController onRoomState = CachedStreamController(); + /// How long should the app wait until it retrys the synchronisation after /// an error? int syncErrorTimeoutSec = 3; diff --git a/lib/src/room.dart b/lib/src/room.dart index 4718e652..f31c00bd 100644 --- a/lib/src/room.dart +++ b/lib/src/room.dart @@ -197,6 +197,8 @@ class Room { } (states[state.type] ??= {})[stateKey] = state; + + client.onRoomState.add(state); } /// ID of the fully read marker event. diff --git a/lib/src/voip/voip.dart b/lib/src/voip/voip.dart index 334418c5..c56849f8 100644 --- a/lib/src/voip/voip.dart +++ b/lib/src/voip/voip.dart @@ -68,9 +68,12 @@ class VoIP { client.onAssertedIdentityReceived.stream .listen((event) => _handleEvent(event, onAssertedIdentityReceived)); - client.onGroupCallRequest.stream.listen((event) { - Logs().v('[VOIP] onGroupCallRequest: type ${event.toJson()}.'); - onRoomStateChanged(event); + client.onRoomState.stream.listen((event) { + if (event.type == EventTypes.GroupCallMemberPrefix || + event.type == EventTypes.GroupCallPrefix) { + Logs().v('[VOIP] onRoomState: type ${event.toJson()}.'); + onRoomStateChanged(event); + } }); client.onToDeviceEvent.stream.listen((event) {