1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-25 05:23:13 +03:00

Use getLocalAge() & add grace period

Use the new local-age field for deciding whether a call is still
valid or not. Also add a grace period so we don't ring half a second
before the call becomes invalid.
This commit is contained in:
David Baker
2020-10-08 11:49:54 +01:00
parent 92c6332143
commit f518ea95f4
2 changed files with 7 additions and 7 deletions

View File

@@ -19,6 +19,10 @@ import {logger} from '../logger';
import { createNewMatrixCall, MatrixCall, CallErrorCode, CallState, CallDirection } from './call';
import { EventType } from '../@types/event';
// Don't ring unless we'd be ringing for at least 3 seconds: the user needs some
// time to press the 'accept' button
const RING_GRACE_PERIOD = 3000;
export class CallEventHandler {
client: any;
calls: Map<string, MatrixCall>;
@@ -119,11 +123,7 @@ export class CallEventHandler {
return; // ignore invites you send
}
// XXX: age is always wrong for events from a stored sync so this doesn't
// really work. getLocalAge works by comparing the event's timestamp to the
// local system clock so is probably worse (ie. if your clock was over a minute
// fast, you wouldn't be able to receive any calls at all).
if (event.getAge() > content.lifetime) {
if (event.getLocalAge() > content.lifetime - RING_GRACE_PERIOD) {
return; // expired call
}