backend: Update room service to utilize MEETING_EMPTY_TIMEOUT and MEETING_DEPARTURE_TIMEOUT for LiveKit room options

This commit is contained in:
Carlos Santos 2025-05-07 11:26:50 +02:00
parent 710b2c0659
commit ecb50ec0e9
2 changed files with 11 additions and 8 deletions

View File

@ -31,7 +31,11 @@ const INTERNAL_CONFIG = {
CRON_JOB_MIN_LOCK_TTL: '59s' as StringValue, // Minimum TTL for cron job locks
// Additional intervals
MIN_FUTURE_TIME_FOR_ROOM_AUTODELETION_DATE: '1h' as StringValue
MIN_FUTURE_TIME_FOR_ROOM_AUTODELETION_DATE: '1h' as StringValue, // Minimum time for room auto-deletion date
// !FIXME (LK BUG): When this is defined, the room will be closed although there are participants
MEETING_EMPTY_TIMEOUT: '' as StringValue, // Seconds to keep the meeting (LK room) open until the first participant joins
// !FIXME (LK BUG): When this is defined, the room will be closed although there are participants
MEETING_DEPARTURE_TIMEOUT: '' as StringValue // Seconds to keep the meeting (LK room) open after the last participant leaves
};
// This function is used to set private configuration values for testing purposes.

View File

@ -23,6 +23,7 @@ import {
TaskSchedulerService,
TokenService
} from './index.js';
import ms from 'ms';
/**
* Service for managing OpenVidu Meet rooms.
@ -94,21 +95,19 @@ export class RoomService {
}
const meetRoom: MeetRoom = await this.getMeetRoom(roomId);
const { MEETING_DEPARTURE_TIMEOUT, MEETING_EMPTY_TIMEOUT } = INTERNAL_CONFIG;
const livekitRoomOptions: CreateOptions = {
name: roomId,
metadata: JSON.stringify({
roomOptions: MeetRoomHelper.toOpenViduOptions(meetRoom)
})
//TODO: Uncomment this when bug in LiveKit is fixed
// When it is defined, the room will be closed although there are participants
// emptyTimeout: ms('20s') / 1000,
// !FIXME: When this is defined, the room will be closed although there are participants
// departureTimeout: ms('20s') / 1000
}),
emptyTimeout: MEETING_EMPTY_TIMEOUT ? ms(MEETING_EMPTY_TIMEOUT) / 1000 : undefined,
departureTimeout: MEETING_DEPARTURE_TIMEOUT ? ms(MEETING_DEPARTURE_TIMEOUT) / 1000 : undefined
// maxParticipants: maxParticipants || undefined,
};
const room = await this.livekitService.createRoom(livekitRoomOptions);
this.logger.verbose(`Room ${roomId} created in LiveKit.`);
this.logger.verbose(`Room ${roomId} created in LiveKit with options: ${JSON.stringify(livekitRoomOptions)}.`);
return room;
}