- enable scalariform for bbb-apps-common

This commit is contained in:
Richard Alam 2019-03-27 13:53:09 -07:00
parent 3f7199c307
commit bee4b79b51
22 changed files with 249 additions and 206 deletions

View File

@ -0,0 +1,31 @@
#alignArguments=false
alignParameters=true
alignSingleLineCaseStatements=true
#alignSingleLineCaseStatements.maxArrowIndent=40
#allowParamGroupsOnNewlines=false
#compactControlReadability=false
#compactStringConcatenation=false
danglingCloseParenthesis=Force
#doubleIndentClassDeclaration=false
doubleIndentConstructorArguments=true
doubleIndentMethodDeclaration=true
firstArgumentOnNewline=Force
firstParameterOnNewline=Force
#formatXml=true
#indentLocalDefs=false
#indentPackageBlocks=true
#indentSpaces=2
#indentWithTabs=false
#multilineScaladocCommentsStartOnFirstLine=false
#newlineAtEndOfFile=false
#placeScaladocAsterisksBeneathSecondAsterisk=false
#preserveSpaceBeforeArguments=false
#rewriteArrowSymbols=false
singleCasePatternOnNewline=false
#spaceBeforeColon=false
#spaceBeforeContextColon=false
#spaceInsideBrackets=false
#spaceInsideParentheses=false
#spacesAroundMultiImports=true
#spacesWithinPatternBinders=true

View File

@ -28,6 +28,10 @@ retrieveManaged := true
Seq(Revolver.settings: _*)
lazy val appsCommons = (project in file(".")).settings(name := "bbb-apps-common", libraryDependencies ++= Dependencies.runtime).settings(compileSettings)
// See https://github.com/scala-ide/scalariform
// Config file is in ./.scalariform.conf
scalariformAutoformat := true
//-----------
// Packaging
//

View File

@ -4,6 +4,8 @@ addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "5.2.4")
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.2-1")
addSbtPlugin("org.scalariform" % "sbt-scalariform" % "1.8.2")
addSbtPlugin("net.vonbuchholtz" % "sbt-dependency-check" % "0.2.9")
addSbtPlugin("org.scalastyle" %% "scalastyle-sbt-plugin" % "1.0.0")

View File

@ -28,7 +28,8 @@ class ClientGWApplication(val msgToClientGW: MsgToClientGW) extends SystemConfig
private val msgSender: MessageSender = new MessageSender(redisPublisher)
private val meetingManagerActorRef = system.actorOf(
MeetingManagerActor.props(msgToRedisEventBus, msgToClientEventBus), "meetingManagerActor")
MeetingManagerActor.props(msgToRedisEventBus, msgToClientEventBus), "meetingManagerActor"
)
msgFromAkkaAppsEventBus.subscribe(meetingManagerActorRef, fromAkkaAppsChannel)
msgFromClientEventBus.subscribe(meetingManagerActorRef, fromClientChannel)
@ -36,19 +37,22 @@ class ClientGWApplication(val msgToClientGW: MsgToClientGW) extends SystemConfig
private val receivedJsonMsgBus = new JsonMsgFromAkkaAppsBus
private val msgToRedisActor = system.actorOf(
MsgToRedisActor.props(msgSender), "msgToRedisActor")
MsgToRedisActor.props(msgSender), "msgToRedisActor"
)
msgToRedisEventBus.subscribe(msgToRedisActor, toRedisChannel)
private val msgToClientJsonActor = system.actorOf(
MsgToClientJsonActor.props(msgToClientGW), "msgToClientJsonActor")
MsgToClientJsonActor.props(msgToClientGW), "msgToClientJsonActor"
)
msgToClientEventBus.subscribe(msgToClientJsonActor, toClientChannel)
private val appsRedisSubscriberActor = system.actorOf(Red5AppsRedisSubscriberActor.props(system, receivedJsonMsgBus), "appsRedisSubscriberActor")
private val receivedJsonMsgHdlrActor = system.actorOf(
ReceivedJsonMsgHdlrActor.props(msgFromAkkaAppsEventBus), "receivedJsonMsgHdlrActor")
ReceivedJsonMsgHdlrActor.props(msgFromAkkaAppsEventBus), "receivedJsonMsgHdlrActor"
)
receivedJsonMsgBus.subscribe(receivedJsonMsgHdlrActor, fromAkkaAppsJsonChannel)

View File

@ -1,7 +1,5 @@
package org.bigbluebutton.client
class ClientInGW(val clientGWApp: ClientGWApplication) extends IClientInGW {
def connect(connInfo: ConnInfo): Unit = {

View File

@ -1,6 +1,6 @@
package org.bigbluebutton.client
import org.bigbluebutton.red5.client.messaging.{BroadcastToMeetingMsg, DirectToClientMsg, ClientMessage, IConnectionInvokerService}
import org.bigbluebutton.red5.client.messaging.{ BroadcastToMeetingMsg, DirectToClientMsg, ClientMessage, IConnectionInvokerService }
sealed trait SystemMessage
case class DisconnectConnection(connId: String) extends SystemMessage

View File

@ -1,11 +1,10 @@
package org.bigbluebutton.client
import akka.actor.{Actor, ActorLogging, Props}
import akka.actor.{ Actor, ActorLogging, Props }
import org.bigbluebutton.client.bus._
import org.bigbluebutton.common2.util.JsonUtil
import org.bigbluebutton.red5.client.messaging._
object MsgToClientJsonActor {
def props(msgToClientGW: MsgToClientGW): Props =
Props(classOf[MsgToClientJsonActor], msgToClientGW)
@ -14,13 +13,12 @@ object MsgToClientJsonActor {
class MsgToClientJsonActor(msgToClientGW: MsgToClientGW) extends Actor with ActorLogging {
def receive = {
case msg: BroadcastMsgToMeeting => handleBroadcastMsg(msg)
case msg: DirectMsgToClient => handleDirectMsg(msg)
case msg: DisconnectClientMsg => handleDisconnectClientMsg(msg)
case msg: BroadcastMsgToMeeting => handleBroadcastMsg(msg)
case msg: DirectMsgToClient => handleDirectMsg(msg)
case msg: DisconnectClientMsg => handleDisconnectClientMsg(msg)
case msg: DisconnectAllMeetingClientsMsg => handleDisconnectAllMeetingClientsMsg(msg)
}
def handleBroadcastMsg(msg: BroadcastMsgToMeeting): Unit = {
val meetingId = msg.meetingId
val msgName = msg.data.envelope.name

View File

@ -1,15 +1,14 @@
package org.bigbluebutton.client
import akka.actor.{Actor, ActorLogging, Props}
import akka.actor.{ Actor, ActorLogging, Props }
import org.bigbluebutton.common2.msgs.BbbCommonEnvJsNodeMsg
import org.bigbluebutton.common2.util.JsonUtil
import scala.util.{Failure, Success}
import org.bigbluebutton.common2.bus.JsonMsgFromAkkaApps
import org.bigbluebutton.api2.bus.MsgFromAkkaAppsEventBus
import scala.util.{ Failure, Success }
import org.bigbluebutton.common2.bus.JsonMsgFromAkkaApps
import org.bigbluebutton.api2.bus.MsgFromAkkaAppsEventBus
import org.bigbluebutton.api2.bus.MsgFromAkkaApps
object ReceivedJsonMsgHdlrActor {
def props(msgFromAkkaAppsEventBus: MsgFromAkkaAppsEventBus): Props =
Props(classOf[ReceivedJsonMsgHdlrActor], msgFromAkkaAppsEventBus)
@ -21,14 +20,13 @@ class ReceivedJsonMsgHdlrActor(val msgFromAkkaAppsEventBus: MsgFromAkkaAppsEvent
def receive = {
case msg: JsonMsgFromAkkaApps => handleReceivedJsonMessage(msg)
case _ => // do nothing
case _ => // do nothing
}
def handleReceivedJsonMessage(msg: JsonMsgFromAkkaApps): Unit = {
//log.debug("****** Received JSON msg " + msg.data)
JsonUtil.fromJson[BbbCommonEnvJsNodeMsg](msg.data) match {
case Success(m) => msgFromAkkaAppsEventBus.publish(MsgFromAkkaApps(fromAkkaAppsChannel, m))
case Success(m) => msgFromAkkaAppsEventBus.publish(MsgFromAkkaApps(fromAkkaAppsChannel, m))
case Failure(ex) => log.error("Failed to deserialize message " + ex)
}

View File

@ -1,6 +1,6 @@
package org.bigbluebutton.client
import org.bigbluebutton.api2.bus.{ MsgFromAkkaApps, MsgFromAkkaAppsEventBus }
package org.bigbluebutton.client
import org.bigbluebutton.api2.bus.{ MsgFromAkkaApps, MsgFromAkkaAppsEventBus }
trait ReceivedMessageRouter {
val msgFromAkkaAppsEventBus: MsgFromAkkaAppsEventBus

View File

@ -1,10 +1,9 @@
package org.bigbluebutton.client.bus
import akka.actor.ActorRef
import akka.event.{EventBus, LookupClassification}
import akka.event.{ EventBus, LookupClassification }
import org.bigbluebutton.client.ConnInfo
sealed trait FromConnectionMsg
case class ConnectMsg(connInfo: ConnInfo) extends FromConnectionMsg
case class DisconnectMsg(connInfo: ConnInfo) extends FromConnectionMsg
@ -28,7 +27,7 @@ class MsgFromClientEventBus extends EventBus with LookupClassification {
// must define a full order over the subscribers, expressed as expected from
// `java.lang.Comparable.compare`
override protected def compareSubscribers(a: Subscriber, b: Subscriber): Int =
a.compareTo(b)
a.compareTo(b)
// determines the initial size of the index data structure
// used internally (i.e. the expected number of different classifiers)

View File

@ -1,7 +1,7 @@
package org.bigbluebutton.client.bus
import akka.actor.ActorRef
import akka.event.{EventBus, LookupClassification}
import akka.event.{ EventBus, LookupClassification }
import org.bigbluebutton.common2.msgs.BbbCommonEnvJsNodeMsg
sealed trait ToConnectionMsg
@ -29,7 +29,7 @@ class MsgToClientEventBus extends EventBus with LookupClassification {
// must define a full order over the subscribers, expressed as expected from
// `java.lang.Comparable.compare`
override protected def compareSubscribers(a: Subscriber, b: Subscriber): Int =
a.compareTo(b)
a.compareTo(b)
// determines the initial size of the index data structure
// used internally (i.e. the expected number of different classifiers)

View File

@ -1,8 +1,8 @@
package org.bigbluebutton.client.bus
import akka.actor.ActorRef
import akka.event.{EventBus, LookupClassification}
import org.bigbluebutton.common2.msgs.{BbbCommonEnvJsNodeMsg}
import akka.event.{ EventBus, LookupClassification }
import org.bigbluebutton.common2.msgs.{ BbbCommonEnvJsNodeMsg }
case class MsgToRedis(val topic: String, val payload: BbbCommonEnvJsNodeMsg)
@ -23,7 +23,7 @@ class MsgToRedisEventBus extends EventBus with LookupClassification {
// must define a full order over the subscribers, expressed as expected from
// `java.lang.Comparable.compare`
override protected def compareSubscribers(a: Subscriber, b: Subscriber): Int =
a.compareTo(b)
a.compareTo(b)
// determines the initial size of the index data structure
// used internally (i.e. the expected number of different classifiers)

View File

@ -21,7 +21,8 @@ object Red5AppsRedisSubscriberActor extends RedisSubscriber with RedisConfigurat
classOf[Red5AppsRedisSubscriberActor],
system, jsonMsgBus,
redisHost, redisPort,
channels, patterns).withDispatcher("akka.redis-subscriber-worker-dispatcher")
channels, patterns
).withDispatcher("akka.redis-subscriber-worker-dispatcher")
}
class Red5AppsRedisSubscriberActor(system: ActorSystem, jsonMsgBus: JsonMsgFromAkkaAppsBus,

View File

@ -5,112 +5,112 @@ import org.bigbluebutton.common2.msgs._
import scala.collection.immutable.HashSet
class AllowedMessageNames {
}
object AllowedMessageNames {
val MESSAGES = HashSet(
// User Messages
ValidateAuthTokenReqMsg.NAME,
GetUsersMeetingReqMsg.NAME,
GetGuestsWaitingApprovalReqMsg.NAME,
UserJoinMeetingReqMsg.NAME,
UserJoinMeetingAfterReconnectReqMsg.NAME,
AssignPresenterReqMsg.NAME,
ChangeUserEmojiCmdMsg.NAME,
UserBroadcastCamStartMsg.NAME,
UserBroadcastCamStopMsg.NAME,
LogoutAndEndMeetingCmdMsg.NAME,
GetRecordingStatusReqMsg.NAME,
MeetingActivityResponseCmdMsg.NAME,
SetRecordingStatusCmdMsg.NAME,
EjectUserFromMeetingCmdMsg.NAME,
IsMeetingMutedReqMsg.NAME,
LockUsersInMeetingCmdMsg.NAME,
LockUserInMeetingCmdMsg.NAME,
GetLockSettingsReqMsg.NAME,
ChangeLockSettingsInMeetingCmdMsg.NAME,
ChangeUserRoleCmdMsg.NAME,
GetGuestPolicyReqMsg.NAME,
SetGuestPolicyCmdMsg.NAME,
GuestsWaitingApprovedMsg.NAME,
UserActivitySignCmdMsg.NAME,
// User Messages
ValidateAuthTokenReqMsg.NAME,
GetUsersMeetingReqMsg.NAME,
GetGuestsWaitingApprovalReqMsg.NAME,
UserJoinMeetingReqMsg.NAME,
UserJoinMeetingAfterReconnectReqMsg.NAME,
AssignPresenterReqMsg.NAME,
ChangeUserEmojiCmdMsg.NAME,
UserBroadcastCamStartMsg.NAME,
UserBroadcastCamStopMsg.NAME,
LogoutAndEndMeetingCmdMsg.NAME,
GetRecordingStatusReqMsg.NAME,
MeetingActivityResponseCmdMsg.NAME,
SetRecordingStatusCmdMsg.NAME,
EjectUserFromMeetingCmdMsg.NAME,
IsMeetingMutedReqMsg.NAME,
LockUsersInMeetingCmdMsg.NAME,
LockUserInMeetingCmdMsg.NAME,
GetLockSettingsReqMsg.NAME,
ChangeLockSettingsInMeetingCmdMsg.NAME,
ChangeUserRoleCmdMsg.NAME,
GetGuestPolicyReqMsg.NAME,
SetGuestPolicyCmdMsg.NAME,
GuestsWaitingApprovedMsg.NAME,
UserActivitySignCmdMsg.NAME,
// Webcams
GetWebcamsOnlyForModeratorReqMsg.NAME,
// Webcams
GetWebcamsOnlyForModeratorReqMsg.NAME,
// Voice
MuteMeetingCmdMsg.NAME,
MuteAllExceptPresentersCmdMsg.NAME,
MuteUserCmdMsg.NAME,
EjectUserFromVoiceCmdMsg.NAME,
// Voice
MuteMeetingCmdMsg.NAME,
MuteAllExceptPresentersCmdMsg.NAME,
MuteUserCmdMsg.NAME,
EjectUserFromVoiceCmdMsg.NAME,
// Chat Messages
GetGroupChatsReqMsg.NAME,
GetGroupChatMsgsReqMsg.NAME,
SendGroupChatMessageMsg.NAME,
ClearPublicChatHistoryPubMsg.NAME,
CreateGroupChatReqMsg.NAME,
UserTypingPubMsg.NAME,
// Chat Messages
GetGroupChatsReqMsg.NAME,
GetGroupChatMsgsReqMsg.NAME,
SendGroupChatMessageMsg.NAME,
ClearPublicChatHistoryPubMsg.NAME,
CreateGroupChatReqMsg.NAME,
UserTypingPubMsg.NAME,
// Presentation Messages
ResizeAndMovePagePubMsg.NAME,
SetCurrentPresentationPubMsg.NAME,
SetCurrentPagePubMsg.NAME,
GetAllPresentationPodsReqMsg.NAME,
RemovePresentationPubMsg.NAME,
SetPresentationDownloadablePubMsg.NAME,
PresentationUploadTokenReqMsg.NAME,
CreateNewPresentationPodPubMsg.NAME,
RemovePresentationPodPubMsg.NAME,
SetPresenterInPodReqMsg.NAME,
// Presentation Messages
ResizeAndMovePagePubMsg.NAME,
SetCurrentPresentationPubMsg.NAME,
SetCurrentPagePubMsg.NAME,
GetAllPresentationPodsReqMsg.NAME,
RemovePresentationPubMsg.NAME,
SetPresentationDownloadablePubMsg.NAME,
PresentationUploadTokenReqMsg.NAME,
CreateNewPresentationPodPubMsg.NAME,
RemovePresentationPodPubMsg.NAME,
SetPresenterInPodReqMsg.NAME,
// Whiteboard Messages
ModifyWhiteboardAccessPubMsg.NAME,
UndoWhiteboardPubMsg.NAME,
ClearWhiteboardPubMsg.NAME,
GetWhiteboardAnnotationsReqMsg.NAME,
SendWhiteboardAnnotationPubMsg.NAME,
SendCursorPositionPubMsg.NAME,
// Whiteboard Messages
ModifyWhiteboardAccessPubMsg.NAME,
UndoWhiteboardPubMsg.NAME,
ClearWhiteboardPubMsg.NAME,
GetWhiteboardAnnotationsReqMsg.NAME,
SendWhiteboardAnnotationPubMsg.NAME,
SendCursorPositionPubMsg.NAME,
// Polling Messages
StartCustomPollReqMsg.NAME,
StartPollReqMsg.NAME,
StopPollReqMsg.NAME,
RespondToPollReqMsg.NAME,
ShowPollResultReqMsg.NAME,
// Polling Messages
StartCustomPollReqMsg.NAME,
StartPollReqMsg.NAME,
StopPollReqMsg.NAME,
RespondToPollReqMsg.NAME,
ShowPollResultReqMsg.NAME,
// Screenshare Messages
GetScreenshareStatusReqMsg.NAME,
// Screenshare Messages
GetScreenshareStatusReqMsg.NAME,
// Caption Messages
SendCaptionHistoryReqMsg.NAME,
UpdateCaptionOwnerPubMsg.NAME,
EditCaptionHistoryPubMsg.NAME,
// Caption Messages
SendCaptionHistoryReqMsg.NAME,
UpdateCaptionOwnerPubMsg.NAME,
EditCaptionHistoryPubMsg.NAME,
// Shared Notes Messages
GetSharedNotesPubMsg.NAME,
CreateSharedNoteReqMsg.NAME,
DestroySharedNoteReqMsg.NAME,
UpdateSharedNoteReqMsg.NAME,
SyncSharedNotePubMsg.NAME,
ClearSharedNotePubMsg.NAME,
// Shared Notes Messages
GetSharedNotesPubMsg.NAME,
CreateSharedNoteReqMsg.NAME,
DestroySharedNoteReqMsg.NAME,
UpdateSharedNoteReqMsg.NAME,
SyncSharedNotePubMsg.NAME,
ClearSharedNotePubMsg.NAME,
// Layout Messages
GetCurrentLayoutReqMsg.NAME,
BroadcastLayoutMsg.NAME,
// Layout Messages
GetCurrentLayoutReqMsg.NAME,
BroadcastLayoutMsg.NAME,
// Breakout
CreateBreakoutRoomsCmdMsg.NAME,
RequestBreakoutJoinURLReqMsg.NAME,
TransferUserToMeetingRequestMsg.NAME,
EndAllBreakoutRoomsMsg.NAME,
BreakoutRoomsListMsg.NAME,
// Breakout
CreateBreakoutRoomsCmdMsg.NAME,
RequestBreakoutJoinURLReqMsg.NAME,
TransferUserToMeetingRequestMsg.NAME,
EndAllBreakoutRoomsMsg.NAME,
BreakoutRoomsListMsg.NAME,
// System
ClientToServerLatencyTracerMsg.NAME,
// Third-party Message
LookUpUserReqMsg.NAME
// System
ClientToServerLatencyTracerMsg.NAME,
// Third-party Message
LookUpUserReqMsg.NAME
)
}

View File

@ -47,7 +47,7 @@ class Connections {
private def remove(id: String): Option[Connection] = {
val conn = conns.get(id)
conn foreach { c => conns -= id }
conn foreach { c => conns -= id }
conn
}
}

View File

@ -1,12 +1,12 @@
package org.bigbluebutton.client.meeting
import akka.actor.ActorContext
import org.bigbluebutton.client.bus.{MsgToRedisEventBus, MsgToClientEventBus}
import org.bigbluebutton.client.bus.{ MsgToRedisEventBus, MsgToClientEventBus }
object Meeting {
def apply(meetingId: String, msgToRedisEventBus: MsgToRedisEventBus,
msgToClientEventBus: MsgToClientEventBus)(implicit context: ActorContext) =
new Meeting(meetingId, msgToRedisEventBus, msgToClientEventBus)(context)
new Meeting(meetingId, msgToRedisEventBus, msgToClientEventBus)(context)
}
class Meeting(val meetingId: String, msgToRedisEventBus: MsgToRedisEventBus,

View File

@ -1,29 +1,29 @@
package org.bigbluebutton.client.meeting
import akka.actor.{Actor, ActorLogging, Props}
import akka.actor.{ Actor, ActorLogging, Props }
import org.bigbluebutton.client.SystemConfiguration
import org.bigbluebutton.client.bus._
import org.bigbluebutton.common2.msgs.{BbbCommonEnvJsNodeMsg, DisconnectAllClientsSysMsg, MessageTypes}
import org.bigbluebutton.common2.msgs.{ BbbCommonEnvJsNodeMsg, DisconnectAllClientsSysMsg, MessageTypes }
object MeetingActor {
def props(meetingId: String, msgToRedisEventBus: MsgToRedisEventBus,
msgToClientEventBus: MsgToClientEventBus): Props =
Props(classOf[MeetingActor], meetingId, msgToRedisEventBus, msgToClientEventBus)
Props(classOf[MeetingActor], meetingId, msgToRedisEventBus, msgToClientEventBus)
}
class MeetingActor(val meetingId: String, msgToRedisEventBus: MsgToRedisEventBus,
msgToClientEventBus: MsgToClientEventBus)
extends Actor with ActorLogging
with SystemConfiguration{
with SystemConfiguration {
private val userMgr = new UsersManager
def receive = {
case msg: ConnectMsg => handleConnectMsg(msg)
case msg: DisconnectMsg => handleDisconnectMsg(msg)
case msg: MsgFromClientMsg => handleMsgFromClientMsg(msg)
case msg: ConnectMsg => handleConnectMsg(msg)
case msg: DisconnectMsg => handleDisconnectMsg(msg)
case msg: MsgFromClientMsg => handleMsgFromClientMsg(msg)
case msg: BbbCommonEnvJsNodeMsg => handleBbbServerMsg(msg)
// TODO: Should keep track of user lifecycle so we can remove when user leaves the meeting.
// TODO: Should keep track of user lifecycle so we can remove when user leaves the meeting.
}
private def createUser(id: String): User = {
@ -33,11 +33,11 @@ class MeetingActor(val meetingId: String, msgToRedisEventBus: MsgToRedisEventBus
def handleConnectMsg(msg: ConnectMsg): Unit = {
//log.debug("**** MeetingActor handleConnectMsg " + msg.connInfo.meetingId)
UsersManager.findWithId(userMgr, msg.connInfo.userId) match {
case Some(m) => m.actorRef forward(msg)
case Some(m) => m.actorRef forward (msg)
case None =>
val m = createUser(msg.connInfo.userId)
UsersManager.add(userMgr, m)
m.actorRef forward(msg)
m.actorRef forward (msg)
}
}
@ -46,16 +46,16 @@ class MeetingActor(val meetingId: String, msgToRedisEventBus: MsgToRedisEventBus
for {
m <- UsersManager.findWithId(userMgr, msg.connInfo.userId)
} yield {
m.actorRef forward(msg)
m.actorRef forward (msg)
}
}
def handleMsgFromClientMsg(msg: MsgFromClientMsg):Unit = {
def handleMsgFromClientMsg(msg: MsgFromClientMsg): Unit = {
//log.debug("**** MeetingActor handleMsgFromClient " + msg.json)
for {
m <- UsersManager.findWithId(userMgr, msg.connInfo.userId)
} yield {
m.actorRef forward(msg)
m.actorRef forward (msg)
}
}
@ -71,9 +71,9 @@ class MeetingActor(val meetingId: String, msgToRedisEventBus: MsgToRedisEventBus
def handleServerMsg(msgType: String, msg: BbbCommonEnvJsNodeMsg): Unit = {
//log.debug("**** MeetingActor handleServerMsg " + msg.envelope.name)
msgType match {
case MessageTypes.DIRECT => handleDirectMessage(msg)
case MessageTypes.DIRECT => handleDirectMessage(msg)
case MessageTypes.BROADCAST_TO_MEETING => handleBroadcastMessage(msg)
case MessageTypes.SYSTEM => handleSystemMessage(msg)
case MessageTypes.SYSTEM => handleSystemMessage(msg)
}
}
@ -84,7 +84,7 @@ class MeetingActor(val meetingId: String, msgToRedisEventBus: MsgToRedisEventBus
m <- UsersManager.findWithId(userMgr, userId)
} yield {
//log.debug("**** MeetingActor forwardToUser " + m.userId)
m.actorRef forward(msg)
m.actorRef forward (msg)
}
}

View File

@ -1,6 +1,5 @@
package org.bigbluebutton.client.meeting
object MeetingManager {
def findWithMeetingId(manager: MeetingManager, meetingId: String): Option[Meeting] = {
manager.toVector.find(m => m.meetingId == meetingId)

View File

@ -1,28 +1,31 @@
package org.bigbluebutton.client.meeting
import akka.actor.{Actor, ActorLogging, Props}
import akka.actor.{ Actor, ActorLogging, Props }
import org.bigbluebutton.client.bus._
import org.bigbluebutton.common2.msgs.{BbbCommonEnvJsNodeMsg, MessageTypes}
import org.bigbluebutton.common2.msgs.{ BbbCommonEnvJsNodeMsg, MessageTypes }
object MeetingManagerActor {
def props(msgToAkkaAppsEventBus: MsgToRedisEventBus,
msgToClientEventBus: MsgToClientEventBus): Props =
def props(
msgToAkkaAppsEventBus: MsgToRedisEventBus,
msgToClientEventBus: MsgToClientEventBus
): Props =
Props(classOf[MeetingManagerActor], msgToAkkaAppsEventBus, msgToClientEventBus)
}
class MeetingManagerActor(msgToRedisEventBus: MsgToRedisEventBus,
msgToClientEventBus: MsgToClientEventBus)
class MeetingManagerActor(
msgToRedisEventBus: MsgToRedisEventBus,
msgToClientEventBus: MsgToClientEventBus
)
extends Actor with ActorLogging {
private val meetingMgr = new MeetingManager
def receive = {
case msg: ConnectMsg => handleConnectMsg(msg)
case msg: DisconnectMsg => handleDisconnectMsg(msg)
case msg: MsgFromClientMsg => handleMsgFromClientMsg(msg)
case msg: ConnectMsg => handleConnectMsg(msg)
case msg: DisconnectMsg => handleDisconnectMsg(msg)
case msg: MsgFromClientMsg => handleMsgFromClientMsg(msg)
case msg: BbbCommonEnvJsNodeMsg => handleBbbServerMsg(msg)
// TODO we should monitor meeting lifecycle so we can remove when meeting ends.
// TODO we should monitor meeting lifecycle so we can remove when meeting ends.
}
def createMeeting(meetingId: String): Meeting = {
@ -31,13 +34,13 @@ class MeetingManagerActor(msgToRedisEventBus: MsgToRedisEventBus,
def handleConnectMsg(msg: ConnectMsg): Unit = {
//log.debug("****** Received handleConnectMsg " + msg)
MeetingManager.findWithMeetingId(meetingMgr, msg.connInfo.meetingId) match {
case Some(m) => m.actorRef forward(msg)
case None =>
val m = createMeeting(msg.connInfo.meetingId)
MeetingManager.add(meetingMgr, m)
m.actorRef forward(msg)
}
MeetingManager.findWithMeetingId(meetingMgr, msg.connInfo.meetingId) match {
case Some(m) => m.actorRef forward (msg)
case None =>
val m = createMeeting(msg.connInfo.meetingId)
MeetingManager.add(meetingMgr, m)
m.actorRef forward (msg)
}
}
def handleDisconnectMsg(msg: DisconnectMsg): Unit = {
@ -45,16 +48,16 @@ class MeetingManagerActor(msgToRedisEventBus: MsgToRedisEventBus,
for {
m <- MeetingManager.findWithMeetingId(meetingMgr, msg.connInfo.meetingId)
} yield {
m.actorRef forward(msg)
m.actorRef forward (msg)
}
}
def handleMsgFromClientMsg(msg: MsgFromClientMsg):Unit = {
def handleMsgFromClientMsg(msg: MsgFromClientMsg): Unit = {
//log.debug("**** MeetingManagerActor handleMsgFromClient " + msg.json)
for {
m <- MeetingManager.findWithMeetingId(meetingMgr, msg.connInfo.meetingId)
} yield {
m.actorRef forward(msg)
m.actorRef forward (msg)
}
}
@ -70,9 +73,9 @@ class MeetingManagerActor(msgToRedisEventBus: MsgToRedisEventBus,
def handleServerMsg(msgType: String, msg: BbbCommonEnvJsNodeMsg): Unit = {
//log.debug("**** MeetingManagerActor handleServerMsg " + msg.envelope.name)
msgType match {
case MessageTypes.DIRECT => handleDirectMessage(msg)
case MessageTypes.DIRECT => handleDirectMessage(msg)
case MessageTypes.BROADCAST_TO_MEETING => handleBroadcastMessage(msg)
case MessageTypes.SYSTEM => handleSystemMessage(msg)
case MessageTypes.SYSTEM => handleSystemMessage(msg)
}
}
@ -81,19 +84,17 @@ class MeetingManagerActor(msgToRedisEventBus: MsgToRedisEventBus,
case Some(meetingId2) => //log.debug("**** MeetingManagerActor forwardToMeeting. Found " + meetingId2)
MeetingManager.findWithMeetingId(meetingMgr, meetingId2) match {
case Some(meetingId2) => //log.debug("**** MeetingManagerActor forwardToMeeting. Found " + meetingId2.meetingId)
case None => //log.debug("**** MeetingManagerActor forwardToMeeting. Could not find meetingId")
case None => //log.debug("**** MeetingManagerActor forwardToMeeting. Could not find meetingId")
}
case None => log.debug("**** MeetingManagerActor forwardToMeeting. Could not find meetingId")
}
for {
meetingId <- msg.envelope.routing.get("meetingId")
m <- MeetingManager.findWithMeetingId(meetingMgr, meetingId)
} yield {
//log.debug("**** MeetingManagerActor forwardToMeeting. " + m.meetingId)
m.actorRef forward(msg)
m.actorRef forward (msg)
}
}
@ -104,7 +105,7 @@ class MeetingManagerActor(msgToRedisEventBus: MsgToRedisEventBus,
}
def handleBroadcastMessage(msg: BbbCommonEnvJsNodeMsg): Unit = {
// log.debug("**** MeetingManagerActor handleBroadcastMessage " + msg.envelope.name)
// log.debug("**** MeetingManagerActor handleBroadcastMessage " + msg.envelope.name)
// In case we want to handle specific message. We can do it here.
forwardToMeeting(msg)
}

View File

@ -1,20 +1,24 @@
package org.bigbluebutton.client.meeting
import akka.actor.ActorContext
import org.bigbluebutton.client.bus.{MsgToRedisEventBus, MsgToClientEventBus}
import org.bigbluebutton.client.bus.{ MsgToRedisEventBus, MsgToClientEventBus }
object User {
def apply(userId: String,
msgToRedisEventBus: MsgToRedisEventBus,
meetingId: String,
msgToClientEventBus: MsgToClientEventBus) (implicit context: ActorContext): User =
def apply(
userId: String,
msgToRedisEventBus: MsgToRedisEventBus,
meetingId: String,
msgToClientEventBus: MsgToClientEventBus
)(implicit context: ActorContext): User =
new User(userId, msgToRedisEventBus, meetingId, msgToClientEventBus)(context)
}
class User(val userId: String,
msgToRedisEventBus: MsgToRedisEventBus,
meetingId: String,
msgToClientEventBus: MsgToClientEventBus)(implicit val context: ActorContext) {
class User(
val userId: String,
msgToRedisEventBus: MsgToRedisEventBus,
meetingId: String,
msgToClientEventBus: MsgToClientEventBus
)(implicit val context: ActorContext) {
val actorRef = context.actorOf(UserActor.props(userId, msgToRedisEventBus,
meetingId, msgToClientEventBus), meetingId + "-" + userId)

View File

@ -1,26 +1,30 @@
package org.bigbluebutton.client.meeting
import akka.actor.{Actor, ActorLogging, Props}
import org.bigbluebutton.client.{ConnInfo, SystemConfiguration}
import akka.actor.{ Actor, ActorLogging, Props }
import org.bigbluebutton.client.{ ConnInfo, SystemConfiguration }
import org.bigbluebutton.client.bus._
import org.bigbluebutton.common2.msgs._
import org.bigbluebutton.common2.util.JsonUtil
import com.fasterxml.jackson.databind.JsonNode
import scala.util.{Failure, Success}
import scala.util.{ Failure, Success }
object UserActor {
def props(userId: String,
msgToRedisEventBus: MsgToRedisEventBus,
meetingId: String,
msgToClientEventBus: MsgToClientEventBus): Props =
def props(
userId: String,
msgToRedisEventBus: MsgToRedisEventBus,
meetingId: String,
msgToClientEventBus: MsgToClientEventBus
): Props =
Props(classOf[UserActor], userId, msgToRedisEventBus, meetingId, msgToClientEventBus)
}
class UserActor(val userId: String,
msgToRedisEventBus: MsgToRedisEventBus,
meetingId: String,
msgToClientEventBus: MsgToClientEventBus)
class UserActor(
val userId: String,
msgToRedisEventBus: MsgToRedisEventBus,
meetingId: String,
msgToClientEventBus: MsgToClientEventBus
)
extends Actor with ActorLogging with SystemConfiguration {
private val conns = new Connections
@ -28,11 +32,11 @@ class UserActor(val userId: String,
def receive = {
case msg: ConnectMsg => handleConnectMsg(msg)
case msg: DisconnectMsg => handleDisconnectMsg(msg)
case msg: MsgFromClientMsg => handleMsgFromClientMsg(msg, true)
case msg: ConnectMsg => handleConnectMsg(msg)
case msg: DisconnectMsg => handleDisconnectMsg(msg)
case msg: MsgFromClientMsg => handleMsgFromClientMsg(msg, true)
case msg: BbbCommonEnvJsNodeMsg => handleBbbServerMsg(msg)
case _ => log.debug("***** UserActor cannot handle msg ")
case _ => log.debug("***** UserActor cannot handle msg ")
}
private def createConnection(id: String, sessionId: String, active: Boolean): Connection = {
@ -92,11 +96,12 @@ class UserActor(val userId: String,
handleMsgFromClientMsg(msgFromClient, false)
}
def handleMsgFromClientMsg(msg: MsgFromClientMsg, applyWhitelist: Boolean):Unit = {
def handleMsgFromClientMsg(msg: MsgFromClientMsg, applyWhitelist: Boolean): Unit = {
def convertToJsonNode(json: String): Option[JsonNode] = {
JsonUtil.toJsonNode(json) match {
case Success(jsonNode) => Some(jsonNode)
case Failure(ex) => log.error("Failed to process client message body " + ex)
case Failure(ex) =>
log.error("Failed to process client message body " + ex)
None
}
}
@ -121,14 +126,14 @@ class UserActor(val userId: String,
// will prevent spoofing of messages. (ralam oct 30, 2017)
val newHeader = BbbClientMsgHeader(msgFromClient.header.name, meetingId, userId)
val msgClient = msgFromClient.copy(header = newHeader)
val routing = Routing.addMsgFromClientRouting(msgClient.header.meetingId, msgClient.header.userId)
val envelope = new BbbCoreEnvelope(msgClient.header.name, routing)
if (msgClient.header.name == "ClientToServerLatencyTracerMsg") {
log.info("-- trace -- " + msg.json)
}
val json = JsonUtil.toJson(msgClient)
for {
jsonNode <- convertToJsonNode(json)
@ -152,11 +157,11 @@ class UserActor(val userId: String,
}
def handleServerMsg(msgType: String, msg: BbbCommonEnvJsNodeMsg): Unit = {
// log.debug("**** UserActor handleServerMsg " + msg)
// log.debug("**** UserActor handleServerMsg " + msg)
msgType match {
case MessageTypes.DIRECT => handleDirectMessage(msg)
case MessageTypes.DIRECT => handleDirectMessage(msg)
case MessageTypes.BROADCAST_TO_MEETING => handleBroadcastMessage(msg)
case MessageTypes.SYSTEM => handleSystemMessage(msg)
case MessageTypes.SYSTEM => handleSystemMessage(msg)
}
}
@ -171,7 +176,7 @@ class UserActor(val userId: String,
val body = core.get("body")
val valid = body.get("valid")
if (valid.asBoolean) {
authorized = true
authorized = true
}
case _ => // let it pass through
}

View File

@ -1,6 +1,5 @@
package org.bigbluebutton.client.meeting
object UsersManager {
def findWithId(manager: UsersManager, id: String): Option[User] = {
manager.toVector.find(m => m.userId == id)