From 92a2cd0d60972aa469b04a00c61c137e42f6933c Mon Sep 17 00:00:00 2001 From: Richard Alam Date: Wed, 24 Oct 2018 12:42:00 -0700 Subject: [PATCH] - delay removing user from user's list in case the user is just reconnecting --- ...rJoinMeetingAfterReconnectReqMsgHdlr.scala | 21 ++++++++++--- .../users/UserJoinMeetingReqMsgHdlr.scala | 31 +++++++++++++------ .../core/apps/users/UserLeaveReqMsgHdlr.scala | 2 ++ .../bigbluebutton/core/models/Users2x.scala | 2 +- .../core/running/MeetingActor.scala | 2 +- 5 files changed, 41 insertions(+), 17 deletions(-) diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/users/UserJoinMeetingAfterReconnectReqMsgHdlr.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/users/UserJoinMeetingAfterReconnectReqMsgHdlr.scala index 47ae355a71..353f531a36 100755 --- a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/users/UserJoinMeetingAfterReconnectReqMsgHdlr.scala +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/users/UserJoinMeetingAfterReconnectReqMsgHdlr.scala @@ -4,6 +4,7 @@ import org.bigbluebutton.common2.msgs.UserJoinMeetingAfterReconnectReqMsg import org.bigbluebutton.core.apps.breakout.BreakoutHdlrHelpers import org.bigbluebutton.core.apps.voice.UserJoinedVoiceConfEvtMsgHdlr import org.bigbluebutton.core.domain.MeetingState2x +import org.bigbluebutton.core.models.Users2x import org.bigbluebutton.core.running.{ BaseMeetingActor, HandlerHelpers, LiveMeeting, OutMsgRouter } trait UserJoinMeetingAfterReconnectReqMsgHdlr extends HandlerHelpers with BreakoutHdlrHelpers with UserJoinedVoiceConfEvtMsgHdlr { @@ -13,13 +14,23 @@ trait UserJoinMeetingAfterReconnectReqMsgHdlr extends HandlerHelpers with Breako val outGW: OutMsgRouter def handleUserJoinMeetingAfterReconnectReqMsg(msg: UserJoinMeetingAfterReconnectReqMsg, state: MeetingState2x): MeetingState2x = { + log.info("Received user joined after reconnecting. user " + msg.body.userId + " meetingId=" + msg.header.meetingId) - val newState = userJoinMeeting(outGW, msg.body.authToken, msg.body.clientType, liveMeeting, state) - if (liveMeeting.props.meetingProp.isBreakout) { - updateParentMeetingWithUsers() + Users2x.findWithIntId(liveMeeting.users2x, msg.body.userId) match { + case Some(reconnectingUser) => + if (reconnectingUser.userLeftFlag.left) { + log.info("Resetting flag that user left meeting. user " + msg.body.userId) + // User has reconnected. Just reset it's flag. ralam Oct 23, 2018 + Users2x.resetUserLeftFlag(liveMeeting.users2x, msg.body.userId) + } + state + case None => + val newState = userJoinMeeting(outGW, msg.body.authToken, msg.body.clientType, liveMeeting, state) + if (liveMeeting.props.meetingProp.isBreakout) { + updateParentMeetingWithUsers() + } + newState } - - newState } } diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/users/UserJoinMeetingReqMsgHdlr.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/users/UserJoinMeetingReqMsgHdlr.scala index 0b214fdbe2..d34e83287c 100755 --- a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/users/UserJoinMeetingReqMsgHdlr.scala +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/users/UserJoinMeetingReqMsgHdlr.scala @@ -2,7 +2,7 @@ package org.bigbluebutton.core.apps.users import org.bigbluebutton.common2.msgs.UserJoinMeetingReqMsg import org.bigbluebutton.core.apps.breakout.BreakoutHdlrHelpers -import org.bigbluebutton.core.models.VoiceUsers +import org.bigbluebutton.core.models.{ Users2x, VoiceUsers } import org.bigbluebutton.core.domain.MeetingState2x import org.bigbluebutton.core.running.{ BaseMeetingActor, HandlerHelpers, LiveMeeting, OutMsgRouter } @@ -13,17 +13,28 @@ trait UserJoinMeetingReqMsgHdlr extends HandlerHelpers with BreakoutHdlrHelpers val outGW: OutMsgRouter def handleUserJoinMeetingReqMsg(msg: UserJoinMeetingReqMsg, state: MeetingState2x): MeetingState2x = { - val newState = userJoinMeeting(outGW, msg.body.authToken, msg.body.clientType, liveMeeting, state) + log.info("Received user joined meeting. user " + msg.body.userId + " meetingId=" + msg.header.meetingId) - if (liveMeeting.props.meetingProp.isBreakout) { - updateParentMeetingWithUsers() + Users2x.findWithIntId(liveMeeting.users2x, msg.body.userId) match { + case Some(reconnectingUser) => + if (reconnectingUser.userLeftFlag.left) { + log.info("Resetting flag that user left meeting. user " + msg.body.userId) + // User has reconnected. Just reset it's flag. ralam Oct 23, 2018 + Users2x.resetUserLeftFlag(liveMeeting.users2x, msg.body.userId) + } + state + case None => + val newState = userJoinMeeting(outGW, msg.body.authToken, msg.body.clientType, liveMeeting, state) + + if (liveMeeting.props.meetingProp.isBreakout) { + updateParentMeetingWithUsers() + } + + // fresh user joined (not due to reconnection). Clear (pop) the cached voice user + VoiceUsers.recoverVoiceUser(liveMeeting.voiceUsers, msg.body.userId) + + newState } - - // fresh user joined (not due to reconnection). Clear (pop) the cached voice user - VoiceUsers.recoverVoiceUser(liveMeeting.voiceUsers, msg.body.userId) - - newState } - } diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/users/UserLeaveReqMsgHdlr.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/users/UserLeaveReqMsgHdlr.scala index cc85bf3938..40b1c7cb11 100755 --- a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/users/UserLeaveReqMsgHdlr.scala +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/users/UserLeaveReqMsgHdlr.scala @@ -15,7 +15,9 @@ trait UserLeaveReqMsgHdlr { def handleUserLeaveReqMsg(msg: UserLeaveReqMsg, state: MeetingState2x): MeetingState2x = { Users2x.findWithIntId(liveMeeting.users2x, msg.body.userId) match { case Some(reconnectingUser) => + log.info("Received user left meeting. user " + msg.body.userId + " meetingId=" + msg.header.meetingId) if (!reconnectingUser.userLeftFlag.left) { + log.info("Setting user left flag. user " + msg.body.userId + " meetingId=" + msg.header.meetingId) // Just flag that user has left as the user might be reconnecting. // An audit will remove this user if it hasn't rejoined after a certain period of time. // ralam oct 23, 2018 diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/models/Users2x.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/models/Users2x.scala index 28a2e523b7..b387876efd 100755 --- a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/models/Users2x.scala +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/models/Users2x.scala @@ -40,7 +40,7 @@ object Users2x { def findAllExpiredUserLeftFlags(users: Users2x): Vector[UserState] = { users.toVector filter (u => u.userLeftFlag.left && u.userLeftFlag.leftOn != 0 && - System.currentTimeMillis() - u.userLeftFlag.leftOn > 60000) + System.currentTimeMillis() - u.userLeftFlag.leftOn > 10000) } def numUsers(users: Users2x): Int = { diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/running/MeetingActor.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/running/MeetingActor.scala index be0ff51cde..dc7ac51b7e 100755 --- a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/running/MeetingActor.scala +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/running/MeetingActor.scala @@ -418,7 +418,7 @@ class MeetingActor( for { u <- Users2x.remove(liveMeeting.users2x, leftUser.intId) } yield { - log.info("User left meeting. meetingId=" + props.meetingProp.intId + " userId=" + u.intId + " user=" + u) + log.info("Removing user from meeting. meetingId=" + props.meetingProp.intId + " userId=" + u.intId + " user=" + u) captionApp2x.handleUserLeavingMsg(leftUser.intId)