Skip to content

Commit

Permalink
Add answer call timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
artemkrachulov committed Sep 14, 2023
1 parent a55cced commit 8f088ee
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion MatrixSDK/VoIP/MXCall.m
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ @interface MXCall ()
The date when the communication has been established.
*/
NSDate *callConnectedDate;

/**
The date for gk.call.answer timestamp event
*/
NSDate *answerConnectedDate;

/**
The total duration of the call. It is computed when the call ends.
Expand Down Expand Up @@ -968,7 +973,11 @@ - (NSUInteger)duration

if (MXCallStateConnected == _state)
{
duration = [[NSDate date] timeIntervalSinceDate:callConnectedDate] * 1000;
if (answerConnectedDate) {
duration = [[NSDate date] timeIntervalSinceDate: answerConnectedDate] * 1000;
} else {
duration = [[NSDate date] timeIntervalSinceDate: callConnectedDate] * 1000;
}
}
else if (MXCallStateEnded == _state)
{
Expand Down Expand Up @@ -1217,6 +1226,11 @@ - (void)handleCallAnswer:(MXEvent *)event
{
MXLogDebug(@"[MXCall][%@] handleCallAnswer", _callId)

if (_isGkCall) {
// reset call connected date
answerConnectedDate = [NSDate dateWithTimeIntervalSince1970: (event.originServerTs / 1000)];
}

if ([self isMyEvent:event])
{
return;
Expand Down

0 comments on commit 8f088ee

Please sign in to comment.