fix: handling of existing calls in `onCallInvite`
This commit is contained in:
parent
02e481ab52
commit
2738451ff6
|
|
@ -384,7 +384,7 @@ class VoIP {
|
||||||
'[glare] got new call ${content.tryGet('call_id')} and currently room id is mapped to ${incomingCallRoomId.tryGet(room.id)}',
|
'[glare] got new call ${content.tryGet('call_id')} and currently room id is mapped to ${incomingCallRoomId.tryGet(room.id)}',
|
||||||
);
|
);
|
||||||
|
|
||||||
if (call != null && call.state == CallState.kEnded) {
|
if (call != null && call.state != CallState.kEnded) {
|
||||||
// Session already exist.
|
// Session already exist.
|
||||||
Logs().v('[VOIP] onCallInvite: Session [$callId] already exist.');
|
Logs().v('[VOIP] onCallInvite: Session [$callId] already exist.');
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -932,5 +932,57 @@ void main() {
|
||||||
expect(room.groupCallParticipantCount('participants_count'), 2);
|
expect(room.groupCallParticipantCount('participants_count'), 2);
|
||||||
expect(room.hasActiveGroupCall, true);
|
expect(room.hasActiveGroupCall, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('call persists after sending invite', () async {
|
||||||
|
CallSession? incomingCall;
|
||||||
|
|
||||||
|
// incoming call should not be created yet
|
||||||
|
incomingCall = voip.calls[voip.currentCID];
|
||||||
|
expect(incomingCall, isNull);
|
||||||
|
expect(incomingCall?.pc, isNull);
|
||||||
|
|
||||||
|
// send invite for the call
|
||||||
|
final outgoingCall = await voip.inviteToCall(
|
||||||
|
room,
|
||||||
|
CallType.kVoice,
|
||||||
|
userId: '@alice:testing.com',
|
||||||
|
);
|
||||||
|
|
||||||
|
// acknowledge the invite
|
||||||
|
await matrix.handleSync(
|
||||||
|
SyncUpdate(
|
||||||
|
nextBatch: 'something',
|
||||||
|
rooms: RoomsUpdate(
|
||||||
|
join: {
|
||||||
|
room.id: JoinedRoomUpdate(
|
||||||
|
timeline: TimelineUpdate(
|
||||||
|
events: [
|
||||||
|
MatrixEvent(
|
||||||
|
type: 'm.call.invite',
|
||||||
|
content: {
|
||||||
|
'lifetime': 60000,
|
||||||
|
'call_id': outgoingCall.callId,
|
||||||
|
'party_id': outgoingCall.localPartyId,
|
||||||
|
'version': '1',
|
||||||
|
'offer': {'type': 'offer', 'sdp': 'sdp'},
|
||||||
|
},
|
||||||
|
senderId: '@alice:testing.com',
|
||||||
|
eventId: 'outgoingCallInviteEvent',
|
||||||
|
originServerTs: DateTime.now(),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
// incoming call pc should be created
|
||||||
|
// if this fails, the call was not properly created
|
||||||
|
incomingCall = voip.calls[voip.currentCID];
|
||||||
|
expect(incomingCall, isNotNull);
|
||||||
|
expect(incomingCall?.pc, isNotNull);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue