set current presenter in pod

This commit is contained in:
Anton Georgiev 2017-10-24 15:49:57 -04:00
parent 31ce060896
commit 8e06408a33
17 changed files with 216 additions and 14 deletions

View File

@ -10,6 +10,7 @@ class PresentationPodHdlrs(implicit val context: ActorContext)
with SetCurrentPresentationPubMsgHdlr
with PresentationConversionCompletedSysPubMsgHdlr
with SetCurrentPagePubMsgHdlr
with SetPresenterInPodReqMsgHdlr
with RemovePresentationPodPubMsgHdlr {
val log = Logging(context.system, getClass)

View File

@ -36,8 +36,7 @@ object PresentationPodsApp {
val presentationVOs = presentationObjects.values.map(p => PresentationVO(p.id, p.name, p.current,
p.pages.values.toVector, p.downloadable)).toVector
PresentationPodVO(pod.id, pod.ownerId, pod.currentPresenter,
pod.authorizedPresenters, presentationVOs)
PresentationPodVO(pod.id, pod.ownerId, pod.currentPresenter, presentationVOs)
}
def updatePresentationPod(state: MeetingState2x, pod: PresentationPod): MeetingState2x = {

View File

@ -40,7 +40,7 @@ trait SetCurrentPagePubMsgHdlr {
updatedPod <- pod.setCurrentPage(presentationId, pageId)
} yield {
if (Users2x.userIsInPresenterGroup(liveMeeting.users2x, userId)) {
if (Users2x.userIsInPresenterGroup(liveMeeting.users2x, userId) || userId.equals(pod.ownerId)) {
broadcastSetCurrentPageEvtMsg(pod.id, presentationId, pageId, userId)
val pods = state.presentationPodManager.addPod(updatedPod)

View File

@ -0,0 +1,56 @@
package org.bigbluebutton.core.apps.presentationpod
import org.bigbluebutton.common2.msgs._
import org.bigbluebutton.core.bus.MessageBus
import org.bigbluebutton.core.domain.MeetingState2x
import org.bigbluebutton.core.running.LiveMeeting
import org.bigbluebutton.core.models.Users2x
trait SetPresenterInPodReqMsgHdlr {
this: PresentationPodHdlrs =>
def handle(
msg: SetPresenterInPodReqMsg, state: MeetingState2x,
liveMeeting: LiveMeeting, bus: MessageBus
): MeetingState2x = {
def broadcastSetPresenterInPodRespMsg(podId: String, nextPresenterId: String, requesterId: String): Unit = {
val routing = Routing.addMsgToClientRouting(
MessageTypes.BROADCAST_TO_MEETING,
liveMeeting.props.meetingProp.intId, requesterId
)
val envelope = BbbCoreEnvelope(SetPresenterInPodRespMsg.NAME, routing)
val header = BbbClientMsgHeader(SetPresenterInPodRespMsg.NAME, liveMeeting.props.meetingProp.intId, requesterId)
val body = SetPresenterInPodRespMsgBody(podId, nextPresenterId)
val event = SetPresenterInPodRespMsg(header, body)
val msgEvent = BbbCommonEnvCoreMsg(envelope, event)
bus.outGW.send(msgEvent)
}
val podId: String = msg.body.podId
val requesterId: String = msg.header.userId
val nextPresenterId: String = msg.body.nextPresenterId
val newState = for {
pod <- PresentationPodsApp.getPresentationPod(state, podId)
} yield {
if (Users2x.userIsInPresenterGroup(liveMeeting.users2x, requesterId) || requesterId.equals(pod.ownerId)) {
val updatedPod = pod.setCurrentPresenter(nextPresenterId)
broadcastSetPresenterInPodRespMsg(pod.id, nextPresenterId, requesterId)
val pods = state.presentationPodManager.addPod(updatedPod)
state.update(pods)
} else {
state
}
}
newState match {
case Some(ns) => ns
case None => state
}
}
}

View File

@ -7,7 +7,7 @@ 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)
new PresentationPod(genId(), ownerId, currentPresenter, Map.empty)
}
}
@ -39,7 +39,6 @@ case class PresentationPod(id: String, ownerId: String, currentPresenter: String
def removePresentation(id: String): PresentationPod = copy(presentations = presentations - id)
def setCurrentPresenter(userId: String): PresentationPod = copy(currentPresenter = userId)
// def getCurrentPresenter(): String = currentPresenter
def getCurrentPresentation(): Option[PresentationInPod] = presentations.values find (p => p.current)

View File

@ -214,6 +214,8 @@ class ReceivedJsonMsgHandlerActor(
routeGenericMsg[CreateNewPresentationPodPubMsg](envelope, jsonNode)
case RemovePresentationPodPubMsg.NAME =>
routeGenericMsg[RemovePresentationPodPubMsg](envelope, jsonNode)
case SetPresenterInPodReqMsg.NAME =>
routeGenericMsg[SetPresenterInPodReqMsg](envelope, jsonNode)
// Caption
case EditCaptionHistoryPubMsg.NAME =>

View File

@ -305,6 +305,7 @@ class MeetingActor(
case m: SetCurrentPresentationPubMsg => state = presentationPodsApp.handle(m, state, liveMeeting, msgBus)
case m: PresentationConversionCompletedSysPubMsg => state = presentationPodsApp.handle(m, state, liveMeeting, msgBus)
case m: SetCurrentPagePubMsg => state = presentationPodsApp.handle(m, state, liveMeeting, msgBus)
case m: SetPresenterInPodReqMsg => state = presentationPodsApp.handle(m, state, liveMeeting, msgBus)
// Caption
case m: EditCaptionHistoryPubMsg => captionApp2x.handle(m, liveMeeting, msgBus)

View File

@ -8,5 +8,4 @@ case class PageVO(id: String, num: Int, thumbUri: String = "", swfUri: String,
yOffset: Double = 0, widthRatio: Double = 100D, heightRatio: Double = 100D)
case class PresentationPodVO(id: String, ownerId: String, currentPresenter: String,
authorizedPresenters: Vector[String],
presentations: Vector[PresentationVO])

View File

@ -28,6 +28,9 @@ object SetCurrentPagePubMsg { val NAME = "SetCurrentPagePubMsg"}
case class SetCurrentPagePubMsg(header: BbbClientMsgHeader, body: SetCurrentPagePubMsgBody) extends StandardMsg
case class SetCurrentPagePubMsgBody(podId: String, presentationId: String, pageId: String)
object SetPresenterInPodReqMsg { val NAME = "SetPresenterInPodReqMsg"}
case class SetPresenterInPodReqMsg(header: BbbClientMsgHeader, body: SetPresenterInPodReqMsgBody) extends StandardMsg
case class SetPresenterInPodReqMsgBody(podId: String, nextPresenterId: String)
// ------------ client to akka-apps ------------
@ -106,6 +109,9 @@ object SetCurrentPageEvtMsg { val NAME = "SetCurrentPageEvtMsg"}
case class SetCurrentPageEvtMsg(header: BbbClientMsgHeader, body: SetCurrentPageEvtMsgBody) extends BbbCoreMsg
case class SetCurrentPageEvtMsgBody(podId: String, presentationId: String, pageId: String)
object SetPresenterInPodRespMsg { val NAME = "SetPresenterInPodRespMsg"}
case class SetPresenterInPodRespMsg(header: BbbClientMsgHeader, body: SetPresenterInPodRespMsgBody) extends StandardMsg
case class SetPresenterInPodRespMsgBody(podId: String, nextPresenterId: String)
// ------------ akka-apps to client ------------

View File

@ -43,6 +43,7 @@ package org.bigbluebutton.modules.present.business
import org.bigbluebutton.modules.present.events.RequestClosePresentationPodEvent;
import org.bigbluebutton.modules.present.events.RequestNewPresentationPodEvent;
import org.bigbluebutton.modules.present.events.RequestPresentationInfoPodEvent;
import org.bigbluebutton.modules.present.events.SetPresenterInPodReqEvent;
import org.bigbluebutton.modules.present.events.RequestAllPodsEvent;
import org.bigbluebutton.modules.present.managers.PresentationSlides;
import org.bigbluebutton.modules.present.model.Page;
@ -283,5 +284,10 @@ package org.bigbluebutton.modules.present.business
public function handleRequestClosePresentationPod(e: RequestClosePresentationPodEvent): void {
sender.requestClosePresentationPod(e.requesterId, e.podId);
}
public function handleSetPresenterInPodReqEvent(e: SetPresenterInPodReqEvent): void {
sender.handleSetPresenterInPodReqEvent(e.podId, e.nextPresenterId);
}
}
}

View File

@ -21,7 +21,6 @@ package org.bigbluebutton.modules.present.events
{
import flash.events.Event;
import flash.net.FileReference;
public class RequestNewPresentationPodEvent extends Event {
public static const REQUEST_NEW_PRES_POD:String = "REQUEST_NEW_PRES_POD";

View File

@ -0,0 +1,38 @@
/**
* BigBlueButton open source conferencing system - http://www.bigbluebutton.org/
*
* Copyright (c) 2017 BigBlueButton Inc. and by respective authors (see below).
*
* This program is free software; you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
* Foundation; either version 3.0 of the License, or (at your option) any later
* version.
*
* BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along
* with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
*
*/
package org.bigbluebutton.modules.present.events
{
import flash.events.Event;
public class SetPresenterInPodReqEvent extends Event {
public static const SET_PRESENTER_IN_POD_REQ:String = "SET_PRESENTER_IN_POD_REQ";
public var podId: String;
public var nextPresenterId: String;
public function SetPresenterInPodReqEvent(podId :String, nextPresenterId: String) {
this.podId = podId;
this.nextPresenterId = nextPresenterId;
super(SET_PRESENTER_IN_POD_REQ, true, false);
}
}
}

View File

@ -0,0 +1,17 @@
package org.bigbluebutton.modules.present.events
{
import flash.events.Event;
public class SetPresenterInPodRespEvent extends Event {
public static const SET_PRESENTER_IN_POD_RESP:String = "SET_PRESENTER_IN_POD_RESP";
public var podId: String;
public var nextPresenterId: String;
public function SetPresenterInPodRespEvent(podId: String, nextPresenterId: String) {
super(SET_PRESENTER_IN_POD_RESP, true, false);
this.podId = podId;
this.nextPresenterId = nextPresenterId;
}
}
}

View File

@ -48,6 +48,8 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
import org.bigbluebutton.modules.present.events.RequestPresentationInfoPodEvent;
import org.bigbluebutton.modules.present.events.GetAllPodsRespEvent;
import org.bigbluebutton.modules.present.events.RequestAllPodsEvent;
import org.bigbluebutton.modules.present.events.SetPresenterInPodReqEvent;
// import org.bigbluebutton.modules.present.events.SetPresenterInPodRespEvent;
import org.bigbluebutton.modules.present.managers.PresentManager;
import org.bigbluebutton.modules.present.model.PresentationPodManager;
import org.bigbluebutton.modules.present.services.PageLoaderService;
@ -187,5 +189,12 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
<MethodInvoker generator="{PresentManager}" method="handleGetAllPodsRespEvent" arguments="{event}" />
</EventHandlers>
<EventHandlers type="{SetPresenterInPodReqEvent.SET_PRESENTER_IN_POD_REQ}" >
<MethodInvoker generator="{PresentProxy}" method="handleSetPresenterInPodReqEvent" arguments="{event}" />
</EventHandlers>
<!--<EventHandlers type="{SetPresenterInPodRespEvent.SET_PRESENTER_IN_POD_RESP}" >-->
<!--<MethodInvoker generator="{PresentManager}" method="handleSetPresenterInPodRespEvent" arguments="{event}" />-->
<!--</EventHandlers>-->
</fx:Declarations>
</EventMap>

View File

@ -41,6 +41,7 @@ package org.bigbluebutton.modules.present.services.messaging
import org.bigbluebutton.modules.present.events.PresentationPodRemoved;
import org.bigbluebutton.modules.present.events.PresentationUploadTokenFail;
import org.bigbluebutton.modules.present.events.PresentationUploadTokenPass;
import org.bigbluebutton.modules.present.events.SetPresenterInPodRespEvent;
import org.bigbluebutton.modules.present.services.Constants;
import org.bigbluebutton.modules.present.services.PresentationService;
import org.bigbluebutton.modules.present.services.messages.PageVO;
@ -106,6 +107,9 @@ package org.bigbluebutton.modules.present.services.messaging
case "GetAllPresentationPodsRespMsg":
handleGetAllPresentationPodsRespMsg(message);
break;
case "SetPresenterInPodRespMsg":
handleSetPresenterInPodRespMsg(message);
break;
}
}
@ -308,5 +312,11 @@ package org.bigbluebutton.modules.present.services.messaging
event.pods = podsAC;
dispatcher.dispatchEvent(event);
}
private function handleSetPresenterInPodRespMsg(msg: Object): void {
var podId: String = msg.body.podId as String;
var nextPresenterId: String = msg.body.nextPresenterId as String;
dispatcher.dispatchEvent(new SetPresenterInPodRespEvent(podId, nextPresenterId));
}
}
}

View File

@ -157,5 +157,24 @@ package org.bigbluebutton.modules.present.services.messaging
JSON.stringify(message)
);
}
public function handleSetPresenterInPodReqEvent(podId: String, nextPresenterId: String):void {
var message:Object = {
header: {name: "SetPresenterInPodReqMsg", meetingId: UsersUtil.getInternalMeetingID(), userId: UsersUtil.getMyUserID()},
body: {nextPresenterId: nextPresenterId, podId: podId}
};
var _nc:ConnectionManager = BBB.initConnectionManager();
_nc.sendMessage2x(
function(result:String):void { },
function(status:String):void { LOGGER.error("Error while setting presenter for pod." + status); },
JSON.stringify(message)
);
}
}
}

View File

@ -64,6 +64,7 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
<mate:Listener type="{GoToPageLocalCommand.GO_TO_PAGE_LOCAL}" method="handleGoToPageLocalCommand" />
<mate:Listener type="{UserAddedToPresenterGroupEvent.USER_ADDED_TO_PRESENTER_GROUP}" method="handleUserAddedToPresenterGroupEvent" />
<mate:Listener type="{UserRemovedFromPresenterGroupEvent.USER_REMOVED_FROM_PRESENTER_GROUP}" method="handleUserRemovedFromPresenterGroupEvent" />
<mate:Listener type="{SetPresenterInPodRespEvent.SET_PRESENTER_IN_POD_RESP}" method="handleSetPresenterInPodRespEvent" />
</fx:Declarations>
<fx:Script>
@ -113,6 +114,8 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
import org.bigbluebutton.modules.present.events.UploadEvent;
import org.bigbluebutton.modules.present.events.RequestNewPresentationPodEvent;
import org.bigbluebutton.modules.present.events.RequestClosePresentationPodEvent;
import org.bigbluebutton.modules.present.events.SetPresenterInPodRespEvent;
import org.bigbluebutton.modules.present.events.SetPresenterInPodReqEvent;
import org.bigbluebutton.main.model.users.events.UserAddedToPresenterGroupEvent;
import org.bigbluebutton.main.model.users.events.UserRemovedFromPresenterGroupEvent;
import org.bigbluebutton.modules.present.model.Page;
@ -124,6 +127,7 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
import org.bigbluebutton.modules.whiteboard.views.WhiteboardTextToolbar;
import org.bigbluebutton.modules.whiteboard.views.WhiteboardToolbar;
import org.bigbluebutton.util.i18n.ResourceUtil;
import org.bigbluebutton.main.api.JSLog;
private static const LOGGER:ILogger = getClassLogger(PresentationWindow);
@ -164,6 +168,7 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
[Bindable]
private var podId: String = "";
private var ownerId: String = "";
private var currentPresenterInPod: String = "";
[Bindable]
private var listOfPodControls:Array = [];
@ -192,7 +197,10 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
private function populatePodDropdown(): void {
listOfPodControls = [];
listOfPodControls.push({label: this.podId,
icon: getStyle('iconClearStatus'), handler: setPresenterInPodHandler});
icon: getStyle('iconClearStatus'), handler: function (): void {} });
listOfPodControls.push({label: UsersUtil.getUserName(this.ownerId),
icon: getStyle('iconClearStatus'), handler: requestPodPresenterChange, data: this.ownerId});
listOfPodControls.push({label: ResourceUtil.getInstance().getString('bbb.presentation.multipod.controls.newPresentationWindowOpen'),
icon: getStyle('iconClearStatus'), handler: newPresentationWindowHandler});
@ -203,8 +211,9 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
var presGroup: ArrayCollection = UsersUtil.getPresenterGroup();
for (var j:int = 0; j < presGroup.length; j++) {
listOfPodControls.push({label: UsersUtil.getUserName(presGroup.getItemAt(j) as String),
icon: getStyle('iconClearStatus'), handler: setPresenterInPodHandler});
var nextPresenterId: String = presGroup.getItemAt(j) as String;
listOfPodControls.push({label: UsersUtil.getUserName(nextPresenterId),
icon: getStyle('iconClearStatus'), handler: requestPodPresenterChange, data: nextPresenterId});
}
}
@ -213,6 +222,9 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
this.podId = _podId;
this.ownerId = _ownerId;
populatePodDropdown();
// the owner is the default currentPresenter for the pod
setPresenterInPodHelper(this.ownerId);
}
public function getPodId(): String { return this.podId; }
@ -220,7 +232,9 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
public function getOwnerId(): String { return this.ownerId; }
private function onPresentationPodControlsClicked():void {
presentationPodControls.selectedItem.handler();
if(presentationPodControls.selectedItem != null) {
presentationPodControls.selectedItem.handler();
}
}
private function newPresentationWindowHandler(): void {
@ -236,8 +250,34 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
localDispatcher.dispatchEvent(event);
}
private function setPresenterInPodHandler(): void {
// TODO
private function requestPodPresenterChange(): void {
if (presentationPodControls.selectedItem == null || presentationPodControls.selectedItem.data == null) {
return;
}
var nextPresenterId: String = presentationPodControls.selectedItem.data as String;
JSLog.warn("__ PresentationWindow::requestPodPresenterChange: " + nextPresenterId, {});
setPresenterInPodHelper(nextPresenterId);
}
private function setPresenterInPodHelper(nextPresenterId: String): void {
localDispatcher.dispatchEvent(new SetPresenterInPodReqEvent(this.podId, nextPresenterId));
}
private function handleSetPresenterInPodRespEvent(event: SetPresenterInPodRespEvent): void {
if (event.podId != this.podId) {
return;
}
// set the dropdown current value? // TODO
this.currentPresenterInPod = event.nextPresenterId as String;
var presentationModel:PresentationModel = PresentationPodManager.getInstance().getPod(podId);
var page : Page = presentationModel.getCurrentPage();
displaySlideNavigationControls(false, !!page);
setupPresenter(this.currentPresenterInPod == UsersUtil.getMyUserID());
}
private function onCreationComplete():void{
@ -461,7 +501,8 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
private function displaySlideNavigationControls(isPresenter:Boolean, activePresentation:Boolean):void {
var showButtons:Boolean = isPresenter && activePresentation;
var showButtons:Boolean = (UsersUtil.getMyUserID() == this.currentPresenterInPod) && activePresentation;
// var showButtons:Boolean = (isPresenter || UsersUtil.getMyUserID() == this.currentPresenterInPod) && activePresentation;
pollStartBtn.visible = showButtons;
quickPollBtn.visible = showButtons;