Skip to content
8 changes: 4 additions & 4 deletions spec/unit/matrixrtc/MatrixRTCSession.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -694,15 +694,15 @@ describe("MatrixRTCSession", () => {
event_id: ownMembershipId,
rel_type: "m.reference",
},
"lifetime": 30000,
"lifetime": 90000,
"sender_ts": expect.any(Number),
});

await didSendNotification;
// And ensure we emitted the DidSendCallNotification event with both payloads
expect(didSendEventFn).toHaveBeenCalledWith({
"event_id": "new-evt",
"lifetime": 30000,
"lifetime": 90000,
"m.mentions": { room: true, user_ids: [] },
"m.relates_to": {
event_id: expect.any(String),
Expand Down Expand Up @@ -751,15 +751,15 @@ describe("MatrixRTCSession", () => {
event_id: ownMembershipEventId,
rel_type: "m.reference",
},
"lifetime": 30000,
"lifetime": 90000,
"sender_ts": expect.any(Number),
});

await didSendNotification;
// And ensure we emitted the DidSendCallNotification event with both payloads
expect(didSendEventFn).toHaveBeenCalledWith({
"event_id": "new-evt",
"lifetime": 30000,
"lifetime": 90000,
"m.mentions": { room: true, user_ids: [] },
"m.relates_to": {
event_id: expect.any(String),
Expand Down
9 changes: 8 additions & 1 deletion src/matrixrtc/MatrixRTCSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ export interface SessionConfig {
* Determines the kind of call this will be.
*/
callIntent?: RTCCallIntent;

/**
* How long (in milliseconds) the callee's client should keep ringing/waiting for an
* answer before the sender gives up and the call notification is considered timed out.
*/
notificationLifetimeMs?: number;
}

// The names follow these principles:
Expand Down Expand Up @@ -697,6 +703,7 @@ export class MatrixRTCSession extends TypedEventEmitter<
notificationType: RTCNotificationType,
callIntent?: RTCCallIntent,
): void {
const lifetime = this.joinConfig?.notificationLifetimeMs ?? 90_000;
const sendNotificationEvent = async (): Promise<{
response: ISendEventResponse;
content: IRTCNotificationContent;
Expand All @@ -709,7 +716,7 @@ export class MatrixRTCSession extends TypedEventEmitter<
rel_type: RelationType.Reference,
},
"sender_ts": Date.now(),
"lifetime": 30_000, // 30 seconds
"lifetime": lifetime,
};
if (callIntent) {
content["m.call.intent"] = callIntent;
Expand Down
Loading