chore: add missing awaits to to_device call events listener

This commit is contained in:
td 2023-05-13 20:05:09 +05:30
parent 89fbd41b4b
commit 8e4f4486b2
No known key found for this signature in database
GPG Key ID: F6D9E9BF14C7D103
1 changed files with 24 additions and 21 deletions

View File

@ -49,6 +49,19 @@ class VoIP {
Map<String, String> incomingCallRoomId = {}; Map<String, String> incomingCallRoomId = {};
VoIP(this.client, this.delegate) : super() { VoIP(this.client, this.delegate) : super() {
Logs().e('11111');
// to populate groupCalls with already present calls
for (final room in client.rooms) {
if (room.activeGroupCallEvents.isNotEmpty) {
for (final groupCall in room.activeGroupCallEvents) {
createGroupCallFromRoomStateEvent(groupCall,
emitHandleNewGroupCall: false);
}
}
Logs().e('doneeeeee');
}
Logs().e('222222');
client.onCallInvite.stream client.onCallInvite.stream
.listen((event) => _handleEvent(event, onCallInvite)); .listen((event) => _handleEvent(event, onCallInvite));
client.onCallAnswer.stream client.onCallAnswer.stream
@ -82,7 +95,7 @@ class VoIP {
}, },
); );
client.onToDeviceEvent.stream.listen((event) { client.onToDeviceEvent.stream.listen((event) async {
Logs().v('[VOIP] onToDeviceEvent: type ${event.toJson()}.'); Logs().v('[VOIP] onToDeviceEvent: type ${event.toJson()}.');
if (event.type == 'org.matrix.call_duplicate_session') { if (event.type == 'org.matrix.call_duplicate_session') {
@ -101,50 +114,40 @@ class VoIP {
final content = event.content; final content = event.content;
switch (event.type) { switch (event.type) {
case EventTypes.CallInvite: case EventTypes.CallInvite:
onCallInvite(roomId, senderId, content); await onCallInvite(roomId, senderId, content);
break; break;
case EventTypes.CallAnswer: case EventTypes.CallAnswer:
onCallAnswer(roomId, senderId, content); await onCallAnswer(roomId, senderId, content);
break; break;
case EventTypes.CallCandidates: case EventTypes.CallCandidates:
onCallCandidates(roomId, senderId, content); await onCallCandidates(roomId, senderId, content);
break; break;
case EventTypes.CallHangup: case EventTypes.CallHangup:
onCallHangup(roomId, senderId, content); await onCallHangup(roomId, senderId, content);
break; break;
case EventTypes.CallReject: case EventTypes.CallReject:
onCallReject(roomId, senderId, content); await onCallReject(roomId, senderId, content);
break; break;
case EventTypes.CallNegotiate: case EventTypes.CallNegotiate:
onCallNegotiate(roomId, senderId, content); await onCallNegotiate(roomId, senderId, content);
break; break;
case EventTypes.CallReplaces: case EventTypes.CallReplaces:
onCallReplaces(roomId, senderId, content); await onCallReplaces(roomId, senderId, content);
break; break;
case EventTypes.CallSelectAnswer: case EventTypes.CallSelectAnswer:
onCallSelectAnswer(roomId, senderId, content); await onCallSelectAnswer(roomId, senderId, content);
break; break;
case EventTypes.CallSDPStreamMetadataChanged: case EventTypes.CallSDPStreamMetadataChanged:
case EventTypes.CallSDPStreamMetadataChangedPrefix: case EventTypes.CallSDPStreamMetadataChangedPrefix:
onSDPStreamMetadataChangedReceived(roomId, senderId, content); await onSDPStreamMetadataChangedReceived(roomId, senderId, content);
break; break;
case EventTypes.CallAssertedIdentity: case EventTypes.CallAssertedIdentity:
onAssertedIdentityReceived(roomId, senderId, content); await onAssertedIdentityReceived(roomId, senderId, content);
break; break;
} }
}); });
delegate.mediaDevices.ondevicechange = _onDeviceChange; delegate.mediaDevices.ondevicechange = _onDeviceChange;
// to populate groupCalls with already present calls
client.rooms.forEach((room) {
if (room.activeGroupCallEvents.isNotEmpty) {
room.activeGroupCallEvents.forEach((element) {
createGroupCallFromRoomStateEvent(element,
emitHandleNewGroupCall: false);
});
}
});
} }
Future<void> _onDeviceChange(dynamic _) async { Future<void> _onDeviceChange(dynamic _) async {