added presentation pod models

This commit is contained in:
Anton Georgiev 2017-09-20 16:58:04 -04:00
parent 5a08c0cfca
commit 9c92780ddb
6 changed files with 103 additions and 14 deletions

View File

@ -9,17 +9,17 @@ case class Presentation(id: String, name: String, current: Boolean = false,
pages: scala.collection.immutable.Map[String, PageVO], downloadable: Boolean)
class PresentationModel {
private var presentations = new scala.collection.immutable.HashMap[String, Presentation]
private var presentations = new scala.collection.immutable.HashMap[String, Presentation] // todo remove
def addPresentation(pres: Presentation) {
def addPresentation(pres: Presentation) { // todo remove
savePresentation(pres)
}
def getPresentations(): Vector[Presentation] = {
def getPresentations(): Vector[Presentation] = { // todo remove
presentations.values.toVector
}
def getCurrentPresentation(): Option[Presentation] = {
def getCurrentPresentation(): Option[Presentation] = { // todo remove
presentations.values find (p => p.current)
}
@ -34,7 +34,7 @@ class PresentationModel {
} yield curPage
}
def removePresentation(presId: String): Option[Presentation] = {
def removePresentation(presId: String): Option[Presentation] = { // todo remove
for {
pres <- presentations.get(presId)
} yield {
@ -43,7 +43,7 @@ class PresentationModel {
}
}
def setCurrentPresentation(presId: String): Option[Presentation] = {
def setCurrentPresentation(presId: String): Option[Presentation] = { // todo remove
getPresentations foreach (curPres => {
if (curPres.id != presId) {
val newPres = curPres.copy(current = false)
@ -60,7 +60,7 @@ class PresentationModel {
}
}
private def savePresentation(pres: Presentation) {
private def savePresentation(pres: Presentation) { // todo remove
presentations += pres.id -> pres
}
@ -105,7 +105,7 @@ class PresentationModel {
}
def changeCurrentPage(presentationId: String, pageId: String): Boolean = {
var foundPage: Boolean = false;
var foundPage: Boolean = false
for {
pres <- presentations.get(presentationId)

View File

@ -2,7 +2,7 @@ package org.bigbluebutton.core.apps.presentation
import org.bigbluebutton.common2.msgs._
import org.bigbluebutton.core.bus.MessageBus
import org.bigbluebutton.core.running.{ LiveMeeting }
import org.bigbluebutton.core.running.LiveMeeting
trait PresentationUploadTokenReqMsgHdlr {
this: PresentationApp2x =>

View File

@ -0,0 +1,21 @@
package org.bigbluebutton.core.apps.presentationpod
import org.bigbluebutton.core.apps.Presentation
import org.bigbluebutton.core.domain.{ BbbSystemConst, MeetingState2x }
import org.bigbluebutton.core.models._
import org.bigbluebutton.core.running.LiveMeeting
object PresentationPodsApp {
def createPresentationPod(id: String, ownerId: String, currentPresenter: String, authorizedPresenters: Vector[String],
presentations: collection.immutable.Map[String, Presentation]): PresentationPod = {
PresentationPodFactory.create(ownerId)
}
def createDefaultPresentationPod(state: MeetingState2x): MeetingState2x = {
val defaultPresPod = PresentationPodFactory.create("the-owner-id")
val podManager = state.presentationPodManager.addPod(defaultPresPod)
state.update(podManager)
}
}

View File

@ -2,6 +2,7 @@ package org.bigbluebutton.core.domain
import org.bigbluebutton.core.apps.BreakoutModel
import org.bigbluebutton.core.models.GroupChats
import org.bigbluebutton.core.models.PresentationPodManager
object MeetingState2x {
@ -9,12 +10,14 @@ object MeetingState2x {
case class MeetingState2x(
groupChats: GroupChats,
presentationPodManager: PresentationPodManager,
breakout: Option[BreakoutModel],
inactivityTracker: MeetingInactivityTracker,
expiryTracker: MeetingExpiryTracker
) {
def update(groupChats: GroupChats): MeetingState2x = copy(groupChats = groupChats)
def update(presPodManager: PresentationPodManager): MeetingState2x = copy(presentationPodManager = presPodManager)
def update(breakout: Option[BreakoutModel]): MeetingState2x = copy(breakout = breakout)
def update(expiry: MeetingExpiryTracker): MeetingState2x = copy(expiryTracker = expiry)
def update(inactivityTracker: MeetingInactivityTracker): MeetingState2x = copy(inactivityTracker = inactivityTracker)

View File

@ -0,0 +1,52 @@
package org.bigbluebutton.core.models
import org.bigbluebutton.core.apps.Presentation
import org.bigbluebutton.core.util.RandomStringGenerator
object PresentationPodFactory {
private def genId(): String = System.currentTimeMillis() + "-" + RandomStringGenerator.randomAlphanumericString(8)
def create(ownerId: String): PresentationPod = {
val currentPresenter = ownerId // default
new PresentationPod(genId(), ownerId, currentPresenter, Vector.empty, Map.empty)
}
}
case class PresentationPod(id: String, ownerId: String, currentPresenter: String, authorizedPresenters: Vector[String],
presentations: collection.immutable.Map[String, Presentation]) {
def addPresentation(presentation: Presentation): PresentationPod = copy(presentations =
presentations + (presentation.id -> presentation))
def removePresentation(id: String): PresentationPod = copy(presentations = presentations - id)
def addAuthorizedPresenter(userId: String): PresentationPod = copy(authorizedPresenters = authorizedPresenters :+ userId)
def removeAuthorizedPresenter(userId: String): PresentationPod = copy(authorizedPresenters =
authorizedPresenters.filterNot(u => u == userId))
def setCurrentPresenter(userId: String): PresentationPod = copy(currentPresenter = userId)
// def getCurrentPresenter(): String = currentPresenter
def getCurrentPresentation(): Option[Presentation] = presentations.values find (p => p.current)
def setCurrentPresentation(presId: String): Option[Presentation] = { // copy(currentPresenter = userId) // ****
presentations.values foreach (curPres => { // unset previous current presentation
if (curPres.id != presId) {
val newPres = curPres.copy(current = false)
addPresentation(newPres)
}
})
presentations.get(presId) match {
case Some(pres) =>
val cp = pres.copy(current = true)
addPresentation(cp)
Some(cp)
case None => None
}
}
}
case class PresentationPodManager(presentationPods: collection.immutable.Map[String, PresentationPod]) {
def addPod(presPod: PresentationPod): PresentationPodManager = copy(presentationPods + (presPod.id -> presPod))
def removePod(id: String): PresentationPodManager = copy(presentationPods = presentationPods - id)
def getNumberOfPods(): Int = presentationPods.size
}

View File

@ -3,6 +3,7 @@ package org.bigbluebutton.core.running
import java.io.{ PrintWriter, StringWriter }
import org.bigbluebutton.core.apps.groupchats.{ GroupChatApp, GroupChatHdlrs }
import org.bigbluebutton.core.apps.presentationpod._
import org.bigbluebutton.core.apps.users._
import org.bigbluebutton.core.apps.whiteboard.ClientToServerLatencyTracerMsgHdlr
import org.bigbluebutton.core.domain.{ BbbSystemConst, MeetingExpiryTracker, MeetingInactivityTracker, MeetingState2x }
@ -131,7 +132,13 @@ class MeetingActor(
meetingExpireWhenLastUserLeftInMs = TimeUtil.minutesToMillis(props.durationProps.meetingExpireWhenLastUserLeftInMinutes)
)
var state = new MeetingState2x(new GroupChats(Map.empty), None, inactivityTracker, expiryTracker)
var state = new MeetingState2x(
new GroupChats(Map.empty),
new PresentationPodManager(Map.empty),
None,
inactivityTracker,
expiryTracker
)
var lastRttTestSentOn = System.currentTimeMillis()
@ -141,6 +148,11 @@ class MeetingActor(
log.debug("NUM GROUP CHATS = " + state.groupChats.findAllPublicChats().length)
// Create a default Presentation Pod
state = PresentationPodsApp.createDefaultPresentationPod(state)
log.debug("\n\n____NUM Presentation Pods = " + state.presentationPodManager.getNumberOfPods())
/*******************************************************************/
//object FakeTestData extends FakeTestData
//FakeTestData.createFakeUsers(liveMeeting)
@ -268,6 +280,7 @@ class MeetingActor(
case m: GetLockSettingsReqMsg => handleGetLockSettingsReqMsg(m)
// Presentation
// case m: SetCurrentPresentationPubMsg => presentationApp2x.handle(m, liveMeeting, msgBus, state)
case m: SetCurrentPresentationPubMsg => presentationApp2x.handle(m, liveMeeting, msgBus)
case m: GetPresentationInfoReqMsg => presentationApp2x.handle(m, liveMeeting, msgBus)
case m: SetCurrentPagePubMsg => presentationApp2x.handle(m, liveMeeting, msgBus)