Merge pull request #4153 from ritzalam/log-meeting-expiry-reasone

- reset last user left timestamp when user joins meeting
This commit is contained in:
Richard Alam 2017-07-27 15:15:46 -04:00 committed by GitHub
commit 7da4d1cba9
2 changed files with 97 additions and 97 deletions

View File

@ -1,95 +1,95 @@
package org.bigbluebutton.core.domain
import org.bigbluebutton.core.util.TimeUtil
case class MeetingInactivityTracker(
val maxInactivityTimeoutInMs: Long,
val warningBeforeMaxInMs: Long,
lastActivityTimestampInMs: Long,
warningSent: Boolean,
warningSentOnTimestampInMs: Long
) {
def setWarningSentAndTimestamp(nowInMs: Long): MeetingInactivityTracker = {
copy(warningSent = true, warningSentOnTimestampInMs = nowInMs)
}
def resetWarningSentAndTimestamp(): MeetingInactivityTracker = {
copy(warningSent = false, warningSentOnTimestampInMs = 0L)
}
def updateLastActivityTimestamp(nowInMs: Long): MeetingInactivityTracker = {
copy(lastActivityTimestampInMs = nowInMs)
}
def hasRecentActivity(nowInMs: Long): Boolean = {
nowInMs - lastActivityTimestampInMs < maxInactivityTimeoutInMs - warningBeforeMaxInMs
}
def isMeetingInactive(nowInMs: Long): Boolean = {
warningSent && (nowInMs - lastActivityTimestampInMs) > maxInactivityTimeoutInMs
}
def timeLeftInMs(nowInMs: Long): Long = {
lastActivityTimestampInMs + maxInactivityTimeoutInMs - nowInMs
}
}
case class MeetingExpiryTracker(
startedOnInMs: Long,
userHasJoined: Boolean,
lastUserLeftOnInMs: Option[Long],
durationInMs: Long,
meetingExpireIfNoUserJoinedInMs: Long,
meetingExpireWhenLastUserLeftInMs: Long
) {
def setUserHasJoined(): MeetingExpiryTracker = {
if (!userHasJoined) {
copy(userHasJoined = true)
} else {
copy()
}
}
def setLastUserLeftOn(timestampInMs: Long): MeetingExpiryTracker = {
copy(lastUserLeftOnInMs = Some(timestampInMs))
}
def hasMeetingExpiredAfterLastUserLeft(timestampInMs: Long): Boolean = {
val expire = for {
lastUserLeftOn <- lastUserLeftOnInMs
} yield {
timestampInMs - lastUserLeftOn > meetingExpireWhenLastUserLeftInMs
}
expire.getOrElse(false)
}
def hasMeetingExpired(timestampInMs: Long): (Boolean, Option[String]) = {
if (hasMeetingExpiredNeverBeenJoined(timestampInMs)) {
(true, Some(MeetingEndReason.ENDED_WHEN_NOT_JOINED))
} else if (meetingOverDuration(timestampInMs)) {
(true, Some(MeetingEndReason.ENDED_AFTER_EXCEEDING_DURATION))
} else if (hasMeetingExpiredAfterLastUserLeft(timestampInMs)) {
(true, Some(MeetingEndReason.ENDED_WHEN_LAST_USER_LEFT))
} else {
(false, None)
}
}
def hasMeetingExpiredNeverBeenJoined(nowInMs: Long): Boolean = {
!userHasJoined && (nowInMs - startedOnInMs > meetingExpireIfNoUserJoinedInMs)
}
def meetingOverDuration(nowInMs: Long): Boolean = {
if (durationInMs == 0) {
false
} else {
nowInMs > startedOnInMs + durationInMs
}
}
def endMeetingTime(): Long = {
startedOnInMs + durationInMs
}
}
package org.bigbluebutton.core.domain
import org.bigbluebutton.core.util.TimeUtil
case class MeetingInactivityTracker(
val maxInactivityTimeoutInMs: Long,
val warningBeforeMaxInMs: Long,
lastActivityTimestampInMs: Long,
warningSent: Boolean,
warningSentOnTimestampInMs: Long
) {
def setWarningSentAndTimestamp(nowInMs: Long): MeetingInactivityTracker = {
copy(warningSent = true, warningSentOnTimestampInMs = nowInMs)
}
def resetWarningSentAndTimestamp(): MeetingInactivityTracker = {
copy(warningSent = false, warningSentOnTimestampInMs = 0L)
}
def updateLastActivityTimestamp(nowInMs: Long): MeetingInactivityTracker = {
copy(lastActivityTimestampInMs = nowInMs)
}
def hasRecentActivity(nowInMs: Long): Boolean = {
nowInMs - lastActivityTimestampInMs < maxInactivityTimeoutInMs - warningBeforeMaxInMs
}
def isMeetingInactive(nowInMs: Long): Boolean = {
warningSent && (nowInMs - lastActivityTimestampInMs) > maxInactivityTimeoutInMs
}
def timeLeftInMs(nowInMs: Long): Long = {
lastActivityTimestampInMs + maxInactivityTimeoutInMs - nowInMs
}
}
case class MeetingExpiryTracker(
startedOnInMs: Long,
userHasJoined: Boolean,
lastUserLeftOnInMs: Option[Long],
durationInMs: Long,
meetingExpireIfNoUserJoinedInMs: Long,
meetingExpireWhenLastUserLeftInMs: Long
) {
def setUserHasJoined(): MeetingExpiryTracker = {
if (!userHasJoined) {
copy(userHasJoined = true, lastUserLeftOnInMs = None)
} else {
this
}
}
def setLastUserLeftOn(timestampInMs: Long): MeetingExpiryTracker = {
copy(lastUserLeftOnInMs = Some(timestampInMs))
}
def hasMeetingExpiredAfterLastUserLeft(timestampInMs: Long): Boolean = {
val expire = for {
lastUserLeftOn <- lastUserLeftOnInMs
} yield {
timestampInMs - lastUserLeftOn > meetingExpireWhenLastUserLeftInMs
}
expire.getOrElse(false)
}
def hasMeetingExpired(timestampInMs: Long): (Boolean, Option[String]) = {
if (hasMeetingExpiredNeverBeenJoined(timestampInMs)) {
(true, Some(MeetingEndReason.ENDED_WHEN_NOT_JOINED))
} else if (meetingOverDuration(timestampInMs)) {
(true, Some(MeetingEndReason.ENDED_AFTER_EXCEEDING_DURATION))
} else if (hasMeetingExpiredAfterLastUserLeft(timestampInMs)) {
(true, Some(MeetingEndReason.ENDED_WHEN_LAST_USER_LEFT))
} else {
(false, None)
}
}
def hasMeetingExpiredNeverBeenJoined(nowInMs: Long): Boolean = {
!userHasJoined && (nowInMs - startedOnInMs > meetingExpireIfNoUserJoinedInMs)
}
def meetingOverDuration(nowInMs: Long): Boolean = {
if (durationInMs == 0) {
false
} else {
nowInMs > startedOnInMs + durationInMs
}
}
def endMeetingTime(): Long = {
startedOnInMs + durationInMs
}
}

View File

@ -2,9 +2,9 @@ package org.bigbluebutton.core.running
import org.bigbluebutton.SystemConfiguration
import org.bigbluebutton.common2.msgs._
import org.bigbluebutton.core.api.{ BreakoutRoomEndedInternalMsg, DestroyMeetingInternalMsg, RecordingStatusChanged }
import org.bigbluebutton.core.api.{ BreakoutRoomEndedInternalMsg, DestroyMeetingInternalMsg }
import org.bigbluebutton.core.bus.{ BigBlueButtonEvent, InternalEventBus }
import org.bigbluebutton.core.domain.{ MeetingExpiryTracker, MeetingState2x }
import org.bigbluebutton.core.domain.{ MeetingState2x }
import org.bigbluebutton.core.models._
import org.bigbluebutton.core2.MeetingStatus2x
import org.bigbluebutton.core2.message.senders.{ MsgBuilder, UserJoinedMeetingEvtMsgBuilder }