From ecb50ec0e95c8f2bd4166e514c3ed1b4e1bdf019 Mon Sep 17 00:00:00 2001 From: Carlos Santos <4a.santos@gmail.com> Date: Wed, 7 May 2025 11:26:50 +0200 Subject: [PATCH] backend: Update room service to utilize MEETING_EMPTY_TIMEOUT and MEETING_DEPARTURE_TIMEOUT for LiveKit room options --- backend/src/config/internal-config.ts | 6 +++++- backend/src/services/room.service.ts | 13 ++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/backend/src/config/internal-config.ts b/backend/src/config/internal-config.ts index 28b5ff0..4aac5f5 100644 --- a/backend/src/config/internal-config.ts +++ b/backend/src/config/internal-config.ts @@ -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. diff --git a/backend/src/services/room.service.ts b/backend/src/services/room.service.ts index b127d6a..4dc5a44 100644 --- a/backend/src/services/room.service.ts +++ b/backend/src/services/room.service.ts @@ -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; }