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:
commit
48d61b76d4
|
|
@ -337,6 +337,7 @@ class VoIP {
|
||||||
await delegate.stopRingtone();
|
await delegate.stopRingtone();
|
||||||
Logs().v('[VOIP] onCallHangup => ${content.toString()}');
|
Logs().v('[VOIP] onCallHangup => ${content.toString()}');
|
||||||
final String callId = content['call_id'];
|
final String callId = content['call_id'];
|
||||||
|
final String partyId = content['party_id'];
|
||||||
final call = calls[callId];
|
final call = calls[callId];
|
||||||
if (call != null) {
|
if (call != null) {
|
||||||
if (call.room.id != roomId) {
|
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}');
|
'Ignoring call hangup for room $roomId claiming to be for call in room ${call.room.id}');
|
||||||
return;
|
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
|
// hangup in any case, either if the other party hung up or we did on another device
|
||||||
await call.terminate(CallParty.kRemote,
|
await call.terminate(CallParty.kRemote,
|
||||||
content['reason'] ?? CallErrorCode.UserHangup, true);
|
content['reason'] ?? CallErrorCode.UserHangup, true);
|
||||||
|
|
@ -358,6 +364,7 @@ class VoIP {
|
||||||
Future<void> onCallReject(
|
Future<void> onCallReject(
|
||||||
String roomId, String senderId, Map<String, dynamic> content) async {
|
String roomId, String senderId, Map<String, dynamic> content) async {
|
||||||
final String callId = content['call_id'];
|
final String callId = content['call_id'];
|
||||||
|
final String partyId = content['party_id'];
|
||||||
Logs().d('Reject received for call ID $callId');
|
Logs().d('Reject received for call ID $callId');
|
||||||
|
|
||||||
final call = calls[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}');
|
'Ignoring call reject for room $roomId claiming to be for call in room ${call.room.id}');
|
||||||
return;
|
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']);
|
await call.onRejectReceived(content['reason']);
|
||||||
} else {
|
} else {
|
||||||
Logs().v('[VOIP] onCallReject: Session [$callId] not found!');
|
Logs().v('[VOIP] onCallReject: Session [$callId] not found!');
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue