Skip to content

Commit

Permalink
fix(breakout-rooms): Fixes the case where a single participant switch…
Browse files Browse the repository at this point in the history
…es 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.
  • Loading branch information
damencho committed Sep 18, 2024
1 parent 1effdfd commit 80cb395
Showing 1 changed file with 44 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand All @@ -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.");
Expand All @@ -999,7 +1002,7 @@ private void maybeStop()
*/
public void breakoutConferenceEnded()
{
maybeStop();
maybeStop(null);
}

@Override
Expand Down Expand Up @@ -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<String> codecs)
{
Expand Down

0 comments on commit 80cb395

Please sign in to comment.