From 030567368a7ec1591ee9b0f8af02c58476659952 Mon Sep 17 00:00:00 2001 From: Anton Georgiev Date: Fri, 20 Oct 2017 17:01:57 -0400 Subject: [PATCH] add/remove user from presenter groups --- .../presentationpod/PresentationPodsApp.scala | 5 --- .../SetCurrentPagePubMsgHdlr.scala | 20 ++++------ .../AddUserToPresenterGroupCmdMsgHdlr.scala | 39 +++++++++++++++++++ ...moveUserFromPresenterGroupCmdMsgHdlr.scala | 39 +++++++++++++++++++ .../core/apps/users/UsersApp.scala | 2 + .../bigbluebutton/core/models/Users2x.scala | 27 +++++++++++++ .../senders/ReceivedJsonMsgHandlerActor.scala | 5 +++ .../core/running/MeetingActor.scala | 17 ++++---- .../bigbluebutton/common2/msgs/UsersMgs.scala | 27 +++++++++++++ .../locale/en_US/bbbResources.properties | 2 + .../main/model/users/UserService.as | 10 +++++ .../events/AddUserToPresenterGroupEvent.as | 35 +++++++++++++++++ .../RemoveUserFromPresenterGroupEvent.as | 35 +++++++++++++++++ .../events/UserAddedToPresenterGroupEvent.as | 35 +++++++++++++++++ .../UserRemovedFromPresenterGroupEvent.as | 35 +++++++++++++++++ .../modules/users/maps/UsersMainEventMap.mxml | 12 +++++- .../modules/users/services/MessageReceiver.as | 20 +++++++++- .../modules/users/services/MessageSender.as | 34 +++++++++++++++- .../users/views/MediaItemRenderer.mxml | 26 ++++++++++++- 19 files changed, 397 insertions(+), 28 deletions(-) create mode 100644 akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/users/AddUserToPresenterGroupCmdMsgHdlr.scala create mode 100644 akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/users/RemoveUserFromPresenterGroupCmdMsgHdlr.scala create mode 100644 bigbluebutton-client/src/org/bigbluebutton/main/model/users/events/AddUserToPresenterGroupEvent.as create mode 100644 bigbluebutton-client/src/org/bigbluebutton/main/model/users/events/RemoveUserFromPresenterGroupEvent.as create mode 100644 bigbluebutton-client/src/org/bigbluebutton/main/model/users/events/UserAddedToPresenterGroupEvent.as create mode 100644 bigbluebutton-client/src/org/bigbluebutton/main/model/users/events/UserRemovedFromPresenterGroupEvent.as diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/presentationpod/PresentationPodsApp.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/presentationpod/PresentationPodsApp.scala index b4306a9743..85570aa404 100644 --- a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/presentationpod/PresentationPodsApp.scala +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/presentationpod/PresentationPodsApp.scala @@ -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) - } - } diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/presentationpod/SetCurrentPagePubMsgHdlr.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/presentationpod/SetCurrentPagePubMsgHdlr.scala index 909a7c20d7..27c51e2bb7 100644 --- a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/presentationpod/SetCurrentPagePubMsgHdlr.scala +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/presentationpod/SetCurrentPagePubMsgHdlr.scala @@ -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 { @@ -28,12 +29,6 @@ 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 @@ -41,17 +36,18 @@ trait SetCurrentPagePubMsgHdlr { 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 { diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/users/AddUserToPresenterGroupCmdMsgHdlr.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/users/AddUserToPresenterGroupCmdMsgHdlr.scala new file mode 100644 index 0000000000..112c5a2bc8 --- /dev/null +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/users/AddUserToPresenterGroupCmdMsgHdlr.scala @@ -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) + } + } + } + +} diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/users/RemoveUserFromPresenterGroupCmdMsgHdlr.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/users/RemoveUserFromPresenterGroupCmdMsgHdlr.scala new file mode 100644 index 0000000000..0ea4b02f66 --- /dev/null +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/users/RemoveUserFromPresenterGroupCmdMsgHdlr.scala @@ -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) + } + } + } + +} diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/users/UsersApp.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/users/UsersApp.scala index 8bb0e15f53..e7dc36f2b2 100755 --- a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/users/UsersApp.scala +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/users/UsersApp.scala @@ -21,6 +21,8 @@ class UsersApp( with SetRecordingStatusCmdMsgHdlr with GetRecordingStatusReqMsgHdlr with AssignPresenterReqMsgHdlr + with AddUserToPresenterGroupCmdMsgHdlr + with RemoveUserFromPresenterGroupCmdMsgHdlr with EjectUserFromMeetingCmdMsgHdlr { val log = Logging(context.system, getClass) 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 4aab105abb..7c9d18fad8 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 @@ -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) @@ -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, diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/pubsub/senders/ReceivedJsonMsgHandlerActor.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/pubsub/senders/ReceivedJsonMsgHandlerActor.scala index f32455984c..dbf39298a0 100755 --- a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/pubsub/senders/ReceivedJsonMsgHandlerActor.scala +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/pubsub/senders/ReceivedJsonMsgHandlerActor.scala @@ -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) 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 23e3843c26..be5b0f12e1 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 @@ -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) diff --git a/bbb-common-message/src/main/scala/org/bigbluebutton/common2/msgs/UsersMgs.scala b/bbb-common-message/src/main/scala/org/bigbluebutton/common2/msgs/UsersMgs.scala index 7c5a72b650..d3a58a73fd 100755 --- a/bbb-common-message/src/main/scala/org/bigbluebutton/common2/msgs/UsersMgs.scala +++ b/bbb-common-message/src/main/scala/org/bigbluebutton/common2/msgs/UsersMgs.scala @@ -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) diff --git a/bigbluebutton-client/locale/en_US/bbbResources.properties b/bigbluebutton-client/locale/en_US/bbbResources.properties index f644248ef9..177455af90 100755 --- a/bigbluebutton-client/locale/en_US/bbbResources.properties +++ b/bigbluebutton-client/locale/en_US/bbbResources.properties @@ -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 diff --git a/bigbluebutton-client/src/org/bigbluebutton/main/model/users/UserService.as b/bigbluebutton-client/src/org/bigbluebutton/main/model/users/UserService.as index 872a907a9a..e7579a47f4 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/main/model/users/UserService.as +++ b/bigbluebutton-client/src/org/bigbluebutton/main/model/users/UserService.as @@ -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; @@ -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); } diff --git a/bigbluebutton-client/src/org/bigbluebutton/main/model/users/events/AddUserToPresenterGroupEvent.as b/bigbluebutton-client/src/org/bigbluebutton/main/model/users/events/AddUserToPresenterGroupEvent.as new file mode 100644 index 0000000000..8770b19b85 --- /dev/null +++ b/bigbluebutton-client/src/org/bigbluebutton/main/model/users/events/AddUserToPresenterGroupEvent.as @@ -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 . + * + */ +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); + } + } +} diff --git a/bigbluebutton-client/src/org/bigbluebutton/main/model/users/events/RemoveUserFromPresenterGroupEvent.as b/bigbluebutton-client/src/org/bigbluebutton/main/model/users/events/RemoveUserFromPresenterGroupEvent.as new file mode 100644 index 0000000000..f260cbd51d --- /dev/null +++ b/bigbluebutton-client/src/org/bigbluebutton/main/model/users/events/RemoveUserFromPresenterGroupEvent.as @@ -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 . + * + */ +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); + } + } +} diff --git a/bigbluebutton-client/src/org/bigbluebutton/main/model/users/events/UserAddedToPresenterGroupEvent.as b/bigbluebutton-client/src/org/bigbluebutton/main/model/users/events/UserAddedToPresenterGroupEvent.as new file mode 100644 index 0000000000..bb9372a0c4 --- /dev/null +++ b/bigbluebutton-client/src/org/bigbluebutton/main/model/users/events/UserAddedToPresenterGroupEvent.as @@ -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 . + * + */ +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); + } + } +} diff --git a/bigbluebutton-client/src/org/bigbluebutton/main/model/users/events/UserRemovedFromPresenterGroupEvent.as b/bigbluebutton-client/src/org/bigbluebutton/main/model/users/events/UserRemovedFromPresenterGroupEvent.as new file mode 100644 index 0000000000..6437c21759 --- /dev/null +++ b/bigbluebutton-client/src/org/bigbluebutton/main/model/users/events/UserRemovedFromPresenterGroupEvent.as @@ -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 . + * + */ +package org.bigbluebutton.main.model.users.events +{ + import flash.events.Event; + + public class UserRemovedFromPresenterGroupEvent extends Event + { + public static const USER_REMOVED_FROM_PRESENTER_GROUP:String = "USER_REMOVED_FROM_PRESENTER_GROUP"; + + public var userId:String; + + public function UserRemovedFromPresenterGroupEvent(userId:String) + { + this.userId = userId; + super(USER_REMOVED_FROM_PRESENTER_GROUP, true, false); + } + } +} diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/users/maps/UsersMainEventMap.mxml b/bigbluebutton-client/src/org/bigbluebutton/modules/users/maps/UsersMainEventMap.mxml index 399613c13b..3c2b4856a9 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/users/maps/UsersMainEventMap.mxml +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/users/maps/UsersMainEventMap.mxml @@ -43,6 +43,8 @@ with BigBlueButton; if not, see . import org.bigbluebutton.main.model.users.events.EmojiStatusEvent; import org.bigbluebutton.main.model.users.events.KickUserEvent; import org.bigbluebutton.main.model.users.events.RoleChangeEvent; + import org.bigbluebutton.main.model.users.events.AddUserToPresenterGroupEvent; + import org.bigbluebutton.main.model.users.events.RemoveUserFromPresenterGroupEvent; @@ -104,7 +106,15 @@ with BigBlueButton; if not, see . - + + + + + + + + + diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/users/services/MessageReceiver.as b/bigbluebutton-client/src/org/bigbluebutton/modules/users/services/MessageReceiver.as index 247709adda..040ada84ca 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/users/services/MessageReceiver.as +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/users/services/MessageReceiver.as @@ -52,6 +52,8 @@ package org.bigbluebutton.modules.users.services import org.bigbluebutton.main.model.users.events.ChangeMyRole; import org.bigbluebutton.main.model.users.events.StreamStartedEvent; import org.bigbluebutton.main.model.users.events.StreamStoppedEvent; + import org.bigbluebutton.main.model.users.events.UserAddedToPresenterGroupEvent; + import org.bigbluebutton.main.model.users.events.UserRemovedFromPresenterGroupEvent; import org.bigbluebutton.modules.screenshare.events.WebRTCViewStreamEvent; import org.bigbluebutton.modules.users.events.MeetingMutedEvent; @@ -200,6 +202,12 @@ package org.bigbluebutton.modules.users.services case "GuestsWaitingApprovedEvtMsg": handleGuestsWaitingApprovedEvtMsg(message); break; + case "UserAddedToPresenterGroupEvtMsg": + handleUserAddedToPresenterGroupEvtMsg(message); + break; + case "UserRemovedFromPresenterGroupEvtMsg": + handleUserRemovedFromPresenterGroupEvtMsg(message); + break; } } @@ -851,7 +859,17 @@ package org.bigbluebutton.modules.users.services dispatcher.dispatchEvent(e); } } - + + private function handleUserAddedToPresenterGroupEvtMsg(msg: Object): void { + var userId: String = msg.body.userId; + dispatcher.dispatchEvent(new UserAddedToPresenterGroupEvent(userId)); + } + + private function handleUserRemovedFromPresenterGroupEvtMsg(msg: Object): void { + var userId: String = msg.body.userId; + dispatcher.dispatchEvent(new UserRemovedFromPresenterGroupEvent(userId)); + } + public function handleGuestPolicyChanged(msg:Object):void { var header: Object = msg.header as Object; var body: Object = msg.body as Object; diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/users/services/MessageSender.as b/bigbluebutton-client/src/org/bigbluebutton/modules/users/services/MessageSender.as index fa319298e3..c69023f952 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/users/services/MessageSender.as +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/users/services/MessageSender.as @@ -424,7 +424,39 @@ package org.bigbluebutton.modules.users.services }, JSON.stringify(message)); } - public function getRoomMuteState():void{ + public function addUserToPresenterGroup(userID:String):void { + var message:Object = { + header: {name: "AddUserToPresenterGroupCmdMsg", meetingId: UsersUtil.getInternalMeetingID(), userId: UsersUtil.getMyUserID()}, + body: {userId: userID, requesterId: UsersUtil.getMyUserID()} + }; + + var _nc:ConnectionManager = BBB.initConnectionManager(); + _nc.sendMessage2x(function(result:String):void { // On successful result + }, function(status:String):void { // status - On error occurred + var logData:Object = UsersUtil.initLogData(); + logData.tags = ["apps"]; + logData.message = "Error occurred adding a user to presenter group."; + LOGGER.info(JSON.stringify(logData)); + }, JSON.stringify(message)); + } + + public function removeUserFromPresenterGroup(userID:String):void { + var message:Object = { + header: {name: "RemoveUserFromPresenterGroupCmdMsg", meetingId: UsersUtil.getInternalMeetingID(), userId: UsersUtil.getMyUserID()}, + body: {userId: userID, requesterId: UsersUtil.getMyUserID()} + }; + + var _nc:ConnectionManager = BBB.initConnectionManager(); + _nc.sendMessage2x(function(result:String):void { // On successful result + }, function(status:String):void { // status - On error occurred + var logData:Object = UsersUtil.initLogData(); + logData.tags = ["apps"]; + logData.message = "Error occurred removing a user from presenter group."; + LOGGER.info(JSON.stringify(logData)); + }, JSON.stringify(message)); + } + + public function getRoomMuteState():void{ var message:Object = { header: {name: "IsMeetingMutedReqMsg", meetingId: UsersUtil.getInternalMeetingID(), userId: UsersUtil.getMyUserID()}, diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/users/views/MediaItemRenderer.mxml b/bigbluebutton-client/src/org/bigbluebutton/modules/users/views/MediaItemRenderer.mxml index f5ca881c0e..1e247082b6 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/users/views/MediaItemRenderer.mxml +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/users/views/MediaItemRenderer.mxml @@ -51,6 +51,8 @@ import org.bigbluebutton.main.model.users.events.ChangeMyRole; import org.bigbluebutton.main.model.users.events.ChangeRoleEvent; import org.bigbluebutton.main.model.users.events.KickUserEvent; + import org.bigbluebutton.main.model.users.events.AddUserToPresenterGroupEvent; + import org.bigbluebutton.main.model.users.events.RemoveUserFromPresenterGroupEvent; import org.bigbluebutton.modules.users.events.UsersRollEvent; import org.bigbluebutton.modules.users.events.ViewCameraEvent; import org.bigbluebutton.modules.users.model.UsersOptions; @@ -151,7 +153,15 @@ dispatchEvent(new KickUserEvent(data.userId)); } } - + + private function addToPresenterGroup(): void { + dispatchEvent(new AddUserToPresenterGroupEvent(data.userId)); + } + + private function removeFromPresenterGroup(): void { + dispatchEvent(new RemoveUserFromPresenterGroupEvent(data.userId)); + } + private function toggleMuteState():void { var e:VoiceConfEvent = new VoiceConfEvent(VoiceConfEvent.MUTE_USER); e.userid = data.userId; @@ -323,6 +333,20 @@ }); } + if (true) { // TODO if belongs to Presenter group + myMenuData.push({ + label: ResourceUtil.getInstance().getString('bbb.users.usersGrid.mediaItemRenderer.addUserToPresenterGroup',[data.name]), + icon: getStyle('iconEject'), + callback: addToPresenterGroup + }); + } else { + myMenuData.push({ + label: ResourceUtil.getInstance().getString('bbb.users.usersGrid.mediaItemRenderer.removeUserFromPresenterGroup',[data.name]), + icon: getStyle('iconEject'), + callback: removeFromPresenterGroup + }); + } + // make sure the previous menu is closed before opening a new one // This could be improved to include a flag that tells if the menu is open, // but it would require an extra listener for the MenuCloseEvent.