From 80cb3952f4dfcacd0072cf00cca074655cd50383 Mon Sep 17 00:00:00 2001 From: damencho Date: Wed, 18 Sep 2024 16:59:56 -0500 Subject: [PATCH] fix(breakout-rooms): Fixes the case where a single participant switches to breakout room. We keep around conferences when there is a breakout room. When a single participant is switching we first get participant left then breakout room is created, so we need to distinguish that the participant left is for joining breakout room. --- .../conference/JitsiMeetConferenceImpl.java | 59 ++++++++++++++----- 1 file changed, 44 insertions(+), 15 deletions(-) diff --git a/jicofo/src/main/java/org/jitsi/jicofo/conference/JitsiMeetConferenceImpl.java b/jicofo/src/main/java/org/jitsi/jicofo/conference/JitsiMeetConferenceImpl.java index 4939627a6..74c5fc07d 100644 --- a/jicofo/src/main/java/org/jitsi/jicofo/conference/JitsiMeetConferenceImpl.java +++ b/jicofo/src/main/java/org/jitsi/jicofo/conference/JitsiMeetConferenceImpl.java @@ -72,6 +72,12 @@ public class JitsiMeetConferenceImpl implements JitsiMeetConference, XmppProvider.Listener { + + /** + * Status used by participants when they are switching from a room to a breakout room. + */ + private static final String BREAKOUT_SWITCHING_STATUS = "switch_room"; + /** * Name of MUC room that is hosting Jitsi Meet conference. */ @@ -276,18 +282,7 @@ public JitsiMeetConferenceImpl( this.jicofoServices = jicofoServices; this.jvbVersion = jvbVersion; - conferenceStartTimeout = TaskPools.getScheduledPool().schedule( - () -> - { - if (includeInStatistics) - { - logger.info("Expiring due to initial timeout."); - } - stop(); - }, - ConferenceConfig.config.getConferenceStartTimeout().toMillis(), - TimeUnit.MILLISECONDS); - + rescheduleConferenceStartTimeout(); visitorCodecs = new PreferenceAggregator( logger, @@ -971,13 +966,14 @@ else if (participants.size() == 0) } } - maybeStop(); + maybeStop(chatRoomMember); } /** * Stop the conference if there are no members and there are no associated breakout room. + * @param chatRoomMember The participant leaving if any. */ - private void maybeStop() + private void maybeStop(ChatRoomMember chatRoomMember) { ChatRoom chatRoom = this.chatRoom; if (chatRoom == null || chatRoom.getMemberCount() == 0) @@ -986,6 +982,13 @@ private void maybeStop() { logger.info("Breakout rooms still present, will not stop."); } + else if (chatRoomMember != null + && chatRoomMember.getPresence() != null + && BREAKOUT_SWITCHING_STATUS.equals(chatRoomMember.getPresence().getStatus())) + { + logger.info("Member moving to breakout room, will not stop."); + rescheduleConferenceStartTimeout(); + } else { logger.info("Last member left, stopping."); @@ -999,7 +1002,7 @@ private void maybeStop() */ public void breakoutConferenceEnded() { - maybeStop(); + maybeStop(null); } @Override @@ -2072,6 +2075,32 @@ private void rescheduleSingleParticipantTimeout() logger.info("Scheduled single person timeout."); } + /** + * (Re)schedules conference start timeout. + */ + private void rescheduleConferenceStartTimeout() + { + conferenceStartTimeout = TaskPools.getScheduledPool().schedule( + () -> + { + if (includeInStatistics) + { + logger.info("Expiring due to initial timeout."); + } + + // in case of last participant leaving to join a breakout room, we want to skip destroy + if (jicofoServices.getFocusManager().hasBreakoutRooms(roomName)) + { + logger.info("Breakout rooms present, will not stop."); + return; + } + + stop(); + }, + ConferenceConfig.config.getConferenceStartTimeout().toMillis(), + TimeUnit.MILLISECONDS); + } + /** Called when a new visitor has been added to the conference. */ private void visitorAdded(List codecs) {