Skip to content

Commit

Permalink
add/remove user from presenter groups
Browse files Browse the repository at this point in the history
  • Loading branch information
antobinary committed Oct 20, 2017
1 parent 04cef71 commit 0305673
Show file tree
Hide file tree
Showing 19 changed files with 397 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,5 @@ object PresentationPodsApp {
PresentationVO(pres.id, pres.name, pres.current, pres.pages.values.toVector, pres.downloadable)
}

def verifyPresenterStatus(state: MeetingState2x, podId: String, userId: String): Option[String] = {
// TODO check if the user belongs in the presenter group
Some(userId)
}

}

Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ 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 SetCurrentPagePubMsgHdlr {

Expand All @@ -28,30 +29,25 @@ trait SetCurrentPagePubMsgHdlr {
bus.outGW.send(msgEvent)
}

// if (Users2x.isPresenter(msg.header.userId, liveMeeting.users2x)) {
// if (setCurrentPage(liveMeeting, msg.body.presentationId, msg.body.pageId)) {
// broadcastEvent(msg)
// }
// }

val podId = msg.body.podId
val userId = msg.header.userId
val presentationId = msg.body.presentationId
val pageId = msg.body.pageId

val newState = for {
pod <- PresentationPodsApp.getPresentationPod(state, podId)
presenter <- PresentationPodsApp.verifyPresenterStatus(state, pod.id, userId)
presentationToModify <- pod.getPresentation(presentationId)
updatedPod <- pod.setCurrentPage(presentationId, pageId)
} yield {

// if user is in the presenter group // TODO
// if (Users2x.isPresenter(userId, liveMeeting.users2x)) {
broadcastSetCurrentPageEvtMsg(pod.id, presentationId, pageId, userId)
if (Users2x.userIsInPresenterGroup(liveMeeting.users2x, userId)) {
broadcastSetCurrentPageEvtMsg(pod.id, presentationId, pageId, userId)

val pods = state.presentationPodManager.addPod(updatedPod)
state.update(pods)
val pods = state.presentationPodManager.addPod(updatedPod)
state.update(pods)
} else {
state
}
}

newState match {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package org.bigbluebutton.core.apps.users

import org.bigbluebutton.common2.msgs._
import org.bigbluebutton.core.models.{ Roles, Users2x }
import org.bigbluebutton.core.running.{ LiveMeeting, OutMsgRouter }

trait AddUserToPresenterGroupCmdMsgHdlr {
this: UsersApp =>

val liveMeeting: LiveMeeting
val outGW: OutMsgRouter

def handleAddUserToPresenterGroupCmdMsg(msg: AddUserToPresenterGroupCmdMsg) {

def broadcastAddUserToPresenterGroup(meetingId: String, userId: String, requesterId: String): Unit = {
val routing = Routing.addMsgToClientRouting(MessageTypes.BROADCAST_TO_MEETING, meetingId, userId)
val envelope = BbbCoreEnvelope(UserAddedToPresenterGroupEvtMsg.NAME, routing)
val header = BbbClientMsgHeader(UserAddedToPresenterGroupEvtMsg.NAME, meetingId, userId)
val body = UserAddedToPresenterGroupEvtMsgBody(userId, requesterId)
val event = UserAddedToPresenterGroupEvtMsg(header, body)
val msgEvent = BbbCommonEnvCoreMsg(envelope, event)

outGW.send(msgEvent)
}

val userId = msg.body.userId
val requesterId = msg.body.requesterId

for {
requester <- Users2x.findWithIntId(liveMeeting.users2x, requesterId)
} yield {
if (requester.role == Roles.MODERATOR_ROLE) {
Users2x.addUserToPresenterGroup(liveMeeting.users2x, userId)
broadcastAddUserToPresenterGroup(liveMeeting.props.meetingProp.intId, userId, requesterId)
}
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package org.bigbluebutton.core.apps.users

import org.bigbluebutton.common2.msgs._
import org.bigbluebutton.core.models.{ Roles, Users2x }
import org.bigbluebutton.core.running.{ LiveMeeting, OutMsgRouter }

trait RemoveUserFromPresenterGroupCmdMsgHdlr {
this: UsersApp =>

val liveMeeting: LiveMeeting
val outGW: OutMsgRouter

def handleRemoveUserFromPresenterGroupCmdMsg(msg: RemoveUserFromPresenterGroupCmdMsg) {

def broadcastRemoveUserFromPresenterGroup(meetingId: String, userId: String, requesterId: String): Unit = {
val routing = Routing.addMsgToClientRouting(MessageTypes.BROADCAST_TO_MEETING, meetingId, userId)
val envelope = BbbCoreEnvelope(UserRemovedFromPresenterGroupEvtMsg.NAME, routing)
val header = BbbClientMsgHeader(UserRemovedFromPresenterGroupEvtMsg.NAME, meetingId, userId)
val body = UserRemovedFromPresenterGroupEvtMsgBody(userId, requesterId)
val event = UserRemovedFromPresenterGroupEvtMsg(header, body)
val msgEvent = BbbCommonEnvCoreMsg(envelope, event)

outGW.send(msgEvent)
}

val userId = msg.body.userId
val requesterId = msg.body.requesterId

for {
requester <- Users2x.findWithIntId(liveMeeting.users2x, requesterId)
} yield {
if (requester.role == Roles.MODERATOR_ROLE) {
Users2x.removeUserFromPresenterGroup(liveMeeting.users2x, userId)
broadcastRemoveUserFromPresenterGroup(liveMeeting.props.meetingProp.intId, userId, requesterId)
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ class UsersApp(
with SetRecordingStatusCmdMsgHdlr
with GetRecordingStatusReqMsgHdlr
with AssignPresenterReqMsgHdlr
with AddUserToPresenterGroupCmdMsgHdlr
with RemoveUserFromPresenterGroupCmdMsgHdlr
with EjectUserFromMeetingCmdMsgHdlr {

val log = Logging(context.system, getClass)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,32 @@ object Users2x {
def findModerator(users: Users2x): Option[UserState] = {
users.toVector.find(u => u.role == Roles.MODERATOR_ROLE)
}

def addUserToPresenterGroup(users: Users2x, userIdToAdd: String): Boolean = {
// returns Boolean(successful operation)
users.updatePresenterGroup(users.presenterGroup.:+(userIdToAdd))
users.presenterGroup.contains(userIdToAdd)
}

def removeUserFromPresenterGroup(users: Users2x, userIdToRemove: String): Boolean = {
// returns Boolean(successful operation)
users.updatePresenterGroup(users.presenterGroup.filterNot(_ == userIdToRemove))
!users.presenterGroup.contains(userIdToRemove)
}

def getPresenterGroupUsers(users2x: Users2x): Vector[String] = {
users2x.presenterGroup
}

def userIsInPresenterGroup(users2x: Users2x, userId: String): Boolean = {
users2x.presenterGroup.contains(userId)
}

}

class Users2x {
private var users: collection.immutable.HashMap[String, UserState] = new collection.immutable.HashMap[String, UserState]
private var presenterGroup: Vector[String] = scala.collection.immutable.Vector.empty

// Collection of users that left the meeting. We keep a cache of the old users state to recover in case
// the user reconnected by refreshing the client. (ralam june 13, 2017)
Expand Down Expand Up @@ -148,6 +170,11 @@ class Users2x {
private def findUserFromCache(intId: String): Option[UserState] = {
usersCache.values.find(u => u.intId == intId)
}

private def updatePresenterGroup(updatedGroup: Vector[String]): Unit = {
presenterGroup = updatedGroup
}

}

case class UserState(intId: String, extId: String, name: String, role: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ class ReceivedJsonMsgHandlerActor(
// Users
case GetUsersMeetingReqMsg.NAME =>
routeGenericMsg[GetUsersMeetingReqMsg](envelope, jsonNode)
case AddUserToPresenterGroupCmdMsg.NAME =>
routeGenericMsg[AddUserToPresenterGroupCmdMsg](envelope, jsonNode)
case RemoveUserFromPresenterGroupCmdMsg.NAME =>
routeGenericMsg[RemoveUserFromPresenterGroupCmdMsg](envelope, jsonNode)

// Poll
case StartCustomPollReqMsg.NAME =>
routeGenericMsg[StartCustomPollReqMsg](envelope, jsonNode)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,13 +221,16 @@ class MeetingActor(
case m: UserJoinedVoiceConfEvtMsg => handleUserJoinedVoiceConfEvtMsg(m)
case m: MeetingActivityResponseCmdMsg =>
state = usersApp.handleMeetingActivityResponseCmdMsg(m, state)
case m: LogoutAndEndMeetingCmdMsg => usersApp.handleLogoutAndEndMeetingCmdMsg(m, state)
case m: SetRecordingStatusCmdMsg => usersApp.handleSetRecordingStatusCmdMsg(m)
case m: GetRecordingStatusReqMsg => usersApp.handleGetRecordingStatusReqMsg(m)
case m: ChangeUserEmojiCmdMsg => handleChangeUserEmojiCmdMsg(m)
case m: EjectUserFromMeetingCmdMsg => usersApp.handleEjectUserFromMeetingCmdMsg(m)
case m: GetUsersMeetingReqMsg => usersApp.handleGetUsersMeetingReqMsg(m)
case m: ChangeUserRoleCmdMsg => usersApp.handleChangeUserRoleCmdMsg(m)
case m: LogoutAndEndMeetingCmdMsg => usersApp.handleLogoutAndEndMeetingCmdMsg(m, state)
case m: SetRecordingStatusCmdMsg => usersApp.handleSetRecordingStatusCmdMsg(m)
case m: GetRecordingStatusReqMsg => usersApp.handleGetRecordingStatusReqMsg(m)
case m: ChangeUserEmojiCmdMsg => handleChangeUserEmojiCmdMsg(m)
case m: EjectUserFromMeetingCmdMsg => usersApp.handleEjectUserFromMeetingCmdMsg(m)
case m: GetUsersMeetingReqMsg => usersApp.handleGetUsersMeetingReqMsg(m)
case m: ChangeUserRoleCmdMsg => usersApp.handleChangeUserRoleCmdMsg(m)
case m: AddUserToPresenterGroupCmdMsg => usersApp.handleAddUserToPresenterGroupCmdMsg(m)
case m: RemoveUserFromPresenterGroupCmdMsg =>
usersApp.handleRemoveUserFromPresenterGroupCmdMsg(m)

// Whiteboard
case m: SendCursorPositionPubMsg => wbApp.handle(m, liveMeeting, msgBus)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,3 +283,30 @@ case class GetVoiceUsersMeetingRespMsgBody(users: Vector[VoiceConfUser])
case class VoiceConfUser(intId: String, voiceUserId: String, callingWith: String, callerName: String,
callerNum: String, muted: Boolean, talking: Boolean, listenOnly: Boolean)

/**
* Sent from client to add user to the presenter group of a meeting.
*/
object AddUserToPresenterGroupCmdMsg { val NAME = "AddUserToPresenterGroupCmdMsg" }
case class AddUserToPresenterGroupCmdMsg(header: BbbClientMsgHeader, body: AddUserToPresenterGroupCmdMsgBody) extends StandardMsg
case class AddUserToPresenterGroupCmdMsgBody(userId: String, requesterId: String)

/**
* Sent to all clients about a user added to the presenter group of a meeting
*/
object UserAddedToPresenterGroupEvtMsg { val NAME = "UserAddedToPresenterGroupEvtMsg" }
case class UserAddedToPresenterGroupEvtMsg(header: BbbClientMsgHeader, body: UserAddedToPresenterGroupEvtMsgBody) extends StandardMsg
case class UserAddedToPresenterGroupEvtMsgBody(userId: String, requesterId: String)

/**
* Sent from client to remove user from the presenter group of a meeting.
*/
object RemoveUserFromPresenterGroupCmdMsg { val NAME = "RemoveUserFromPresenterGroupCmdMsg" }
case class RemoveUserFromPresenterGroupCmdMsg(header: BbbClientMsgHeader, body: RemoveUserFromPresenterGroupCmdMsgBody) extends StandardMsg
case class RemoveUserFromPresenterGroupCmdMsgBody(userId: String, requesterId: String)

/**
* Sent to all clients about a user removed from the presenter group of a meeting
*/
object UserRemovedFromPresenterGroupEvtMsg { val NAME = "UserRemovedFromPresenterGroupEvtMsg" }
case class UserRemovedFromPresenterGroupEvtMsg(header: BbbClientMsgHeader, body: UserRemovedFromPresenterGroupEvtMsgBody) extends StandardMsg
case class UserRemovedFromPresenterGroupEvtMsgBody(userId: String, requesterId: String)
2 changes: 2 additions & 0 deletions bigbluebutton-client/locale/en_US/bbbResources.properties
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@ bbb.users.usersGrid.mediaItemRenderer.pushToMute = Mute {0}
bbb.users.usersGrid.mediaItemRenderer.pushToLock = Lock {0}
bbb.users.usersGrid.mediaItemRenderer.pushToUnlock = Unlock {0}
bbb.users.usersGrid.mediaItemRenderer.kickUser = Kick {0}
bbb.users.usersGrid.mediaItemRenderer.addUserToPresenterGroup = Add {0} to presenter group
bbb.users.usersGrid.mediaItemRenderer.removeUserFromPresenterGroup = Remove {0} from presenter group
bbb.users.usersGrid.mediaItemRenderer.webcam = Webcam shared
bbb.users.usersGrid.mediaItemRenderer.micOff = Microphone off
bbb.users.usersGrid.mediaItemRenderer.micOn = Microphone on
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ package org.bigbluebutton.main.model.users
import org.bigbluebutton.main.model.users.events.KickUserEvent;
import org.bigbluebutton.main.model.users.events.RoleChangeEvent;
import org.bigbluebutton.main.model.users.events.UsersConnectionEvent;
import org.bigbluebutton.main.model.users.events.AddUserToPresenterGroupEvent;
import org.bigbluebutton.main.model.users.events.RemoveUserFromPresenterGroupEvent;
import org.bigbluebutton.modules.users.services.MessageReceiver;
import org.bigbluebutton.modules.users.services.MessageSender;

Expand Down Expand Up @@ -262,6 +264,14 @@ package org.bigbluebutton.main.model.users
if (this.isModerator()) sender.kickUser(e.userid);
}

public function addUserToPresenterGroup(e: AddUserToPresenterGroupEvent): void {
if (this.isModerator()) sender.addUserToPresenterGroup(e.userId);
}

public function removeUserFromPresenterGroup(e: RemoveUserFromPresenterGroupEvent): void {
if (this.isModerator()) sender.removeUserFromPresenterGroup(e.userId);
}

public function changeRole(e:ChangeRoleEvent):void {
if (this.isModerator()) sender.changeRole(e.userid, e.role);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* 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.main.model.users.events
{
import flash.events.Event;

public class AddUserToPresenterGroupEvent extends Event
{
public static const ADD_USER_TO_PRESENTER_GROUP:String = "ADD_USER_TO_PRESENTER_GROUP";

public var userId:String;

public function AddUserToPresenterGroupEvent(userId:String)
{
this.userId = userId;
super(ADD_USER_TO_PRESENTER_GROUP, true, false);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* 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.main.model.users.events
{
import flash.events.Event;

public class RemoveUserFromPresenterGroupEvent extends Event
{
public static const REMOVE_USER_FROM_PRESENTER_GROUP:String = "REMOVE_USER_FROM_PRESENTER_GROUP";

public var userId:String;

public function RemoveUserFromPresenterGroupEvent(userId:String)
{
this.userId = userId;
super(REMOVE_USER_FROM_PRESENTER_GROUP, true, false);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* 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.main.model.users.events
{
import flash.events.Event;

public class UserAddedToPresenterGroupEvent extends Event
{
public static const USER_ADDED_TO_PRESENTER_GROUP:String = "USER_ADDED_TO_PRESENTER_GROUP";

public var userId:String;

public function UserAddedToPresenterGroupEvent(userId:String)
{
this.userId = userId;
super(USER_ADDED_TO_PRESENTER_GROUP, true, false);
}
}
}
Loading

0 comments on commit 0305673

Please sign in to comment.