Merge pull request #1615 from famedly/karthi/handle-call-on-multiple-devices

handle call when multiple devices are involved for one account
This commit is contained in:
Karthikeyan S 2023-11-29 13:05:39 +05:30 committed by GitHub
commit 48d61b76d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 0 deletions

View File

@ -337,6 +337,7 @@ class VoIP {
await delegate.stopRingtone();
Logs().v('[VOIP] onCallHangup => ${content.toString()}');
final String callId = content['call_id'];
final String partyId = content['party_id'];
final call = calls[callId];
if (call != null) {
if (call.room.id != roomId) {
@ -344,6 +345,11 @@ class VoIP {
'Ignoring call hangup for room $roomId claiming to be for call in room ${call.room.id}');
return;
}
if (call.remotePartyId != null && call.remotePartyId != partyId) {
Logs().w(
'Ignoring call hangup from sender with a different party_id $partyId for call in room ${call.room.id}');
return;
}
// hangup in any case, either if the other party hung up or we did on another device
await call.terminate(CallParty.kRemote,
content['reason'] ?? CallErrorCode.UserHangup, true);
@ -358,6 +364,7 @@ class VoIP {
Future<void> onCallReject(
String roomId, String senderId, Map<String, dynamic> content) async {
final String callId = content['call_id'];
final String partyId = content['party_id'];
Logs().d('Reject received for call ID $callId');
final call = calls[callId];
@ -367,6 +374,11 @@ class VoIP {
'Ignoring call reject for room $roomId claiming to be for call in room ${call.room.id}');
return;
}
if (call.remotePartyId != null && call.remotePartyId != partyId) {
Logs().w(
'Ignoring call reject from sender with a different party_id $partyId for call in room ${call.room.id}');
return;
}
await call.onRejectReceived(content['reason']);
} else {
Logs().v('[VOIP] onCallReject: Session [$callId] not found!');