Merge branch 'td/moreMissingAwaitsbahh' into 'main'

chore: add missing awaits to to_device call events listener

See merge request famedly/company/frontend/famedlysdk!1295
This commit is contained in:
Malin Errenst 2023-05-15 19:52:03 +00:00
commit ac0fdc1deb
1 changed files with 21 additions and 21 deletions

View File

@ -49,6 +49,16 @@ class VoIP {
Map<String, String> incomingCallRoomId = {};
VoIP(this.client, this.delegate) : super() {
// 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);
}
}
}
client.onCallInvite.stream
.listen((event) => _handleEvent(event, onCallInvite));
client.onCallAnswer.stream
@ -82,7 +92,7 @@ class VoIP {
},
);
client.onToDeviceEvent.stream.listen((event) {
client.onToDeviceEvent.stream.listen((event) async {
Logs().v('[VOIP] onToDeviceEvent: type ${event.toJson()}.');
if (event.type == 'org.matrix.call_duplicate_session') {
@ -101,50 +111,40 @@ class VoIP {
final content = event.content;
switch (event.type) {
case EventTypes.CallInvite:
onCallInvite(roomId, senderId, content);
await onCallInvite(roomId, senderId, content);
break;
case EventTypes.CallAnswer:
onCallAnswer(roomId, senderId, content);
await onCallAnswer(roomId, senderId, content);
break;
case EventTypes.CallCandidates:
onCallCandidates(roomId, senderId, content);
await onCallCandidates(roomId, senderId, content);
break;
case EventTypes.CallHangup:
onCallHangup(roomId, senderId, content);
await onCallHangup(roomId, senderId, content);
break;
case EventTypes.CallReject:
onCallReject(roomId, senderId, content);
await onCallReject(roomId, senderId, content);
break;
case EventTypes.CallNegotiate:
onCallNegotiate(roomId, senderId, content);
await onCallNegotiate(roomId, senderId, content);
break;
case EventTypes.CallReplaces:
onCallReplaces(roomId, senderId, content);
await onCallReplaces(roomId, senderId, content);
break;
case EventTypes.CallSelectAnswer:
onCallSelectAnswer(roomId, senderId, content);
await onCallSelectAnswer(roomId, senderId, content);
break;
case EventTypes.CallSDPStreamMetadataChanged:
case EventTypes.CallSDPStreamMetadataChangedPrefix:
onSDPStreamMetadataChangedReceived(roomId, senderId, content);
await onSDPStreamMetadataChangedReceived(roomId, senderId, content);
break;
case EventTypes.CallAssertedIdentity:
onAssertedIdentityReceived(roomId, senderId, content);
await onAssertedIdentityReceived(roomId, senderId, content);
break;
}
});
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 {