trigger syncing with state from akka-apps

This commit is contained in:
Anton Georgiev 2017-06-30 10:58:49 -04:00
parent 3f9ac22a1c
commit 2e0f6d8610
15 changed files with 161 additions and 5 deletions

View File

@ -36,6 +36,7 @@ trait SystemConfiguration {
lazy val toAkkaAppsRedisChannel = Try(config.getString("redis.toAkkaAppsRedisChannel")).getOrElse("to-akka-apps-redis-channel") lazy val toAkkaAppsRedisChannel = Try(config.getString("redis.toAkkaAppsRedisChannel")).getOrElse("to-akka-apps-redis-channel")
lazy val fromAkkaAppsRedisChannel = Try(config.getString("redis.fromAkkaAppsRedisChannel")).getOrElse("from-akka-apps-redis-channel") lazy val fromAkkaAppsRedisChannel = Try(config.getString("redis.fromAkkaAppsRedisChannel")).getOrElse("from-akka-apps-redis-channel")
lazy val toHTML5RedisChannel = Try(config.getString("redis.toHTML5RedisChannel")).getOrElse("to-html5-redis-channel")
lazy val fromAkkaAppsChannel = Try(config.getString("eventBus.fromAkkaAppsChannel")).getOrElse("from-akka-apps-channel") lazy val fromAkkaAppsChannel = Try(config.getString("eventBus.fromAkkaAppsChannel")).getOrElse("from-akka-apps-channel")
lazy val toAkkaAppsChannel = Try(config.getString("eventBus.toAkkaAppsChannel")).getOrElse("to-akka-apps-channel") lazy val toAkkaAppsChannel = Try(config.getString("eventBus.toAkkaAppsChannel")).getOrElse("to-akka-apps-channel")
lazy val fromClientChannel = Try(config.getString("eventBus.fromClientChannel")).getOrElse("from-client-channel") lazy val fromClientChannel = Try(config.getString("eventBus.fromClientChannel")).getOrElse("from-client-channel")

View File

@ -74,6 +74,7 @@ class BigBlueButtonActor(val system: ActorSystem,
msg.core match { msg.core match {
case m: CreateMeetingReqMsg => handleCreateMeetingReqMsg(m) case m: CreateMeetingReqMsg => handleCreateMeetingReqMsg(m)
case m: RegisterUserReqMsg => handleRegisterUserReqMsg(m) case m: RegisterUserReqMsg => handleRegisterUserReqMsg(m)
case m: GetAllMeetingsReqMsg => handleGetAllMeetingsReqMsg(m)
case _ => log.warning("Cannot handle " + msg.envelope.name) case _ => log.warning("Cannot handle " + msg.envelope.name)
} }
} }
@ -135,6 +136,12 @@ class BigBlueButtonActor(val system: ActorSystem,
} }
private def handleGetAllMeetingsReqMsg(msg: GetAllMeetingsReqMsg): Unit = {
RunningMeetings.meetings(meetings).foreach(m => {
m.actorRef ! msg
})
}
private def findMeetingWithVoiceConfId(voiceConfId: String): Option[RunningMeeting] = { private def findMeetingWithVoiceConfId(voiceConfId: String): Option[RunningMeeting] = {
RunningMeetings.findMeetingWithVoiceConfId(meetings, voiceConfId) RunningMeetings.findMeetingWithVoiceConfId(meetings, voiceConfId)
} }

View File

@ -0,0 +1,21 @@
package org.bigbluebutton.core.apps.meeting
import org.bigbluebutton.common2.domain.DefaultProps
import org.bigbluebutton.core.OutMessageGateway
import org.bigbluebutton.common2.msgs._
trait SyncGetMeetingInfoRespMsgHdlr {
val outGW: OutMessageGateway
def handleSyncGetMeetingInfoRespMsg(props: DefaultProps): Unit = {
val routing = Routing.addMsgToClientRouting(MessageTypes.DIRECT, props.meetingProp.intId, "nodeJSapp")
val envelope = BbbCoreEnvelope(SyncGetMeetingInfoRespMsg.NAME, routing)
val header = BbbCoreBaseHeader(SyncGetMeetingInfoRespMsg.NAME)
val body = SyncGetMeetingInfoRespMsgBody(props)
val event = SyncGetMeetingInfoRespMsg(header, body)
val msgEvent = BbbCommonEnvCoreMsg(envelope, event)
outGW.send(msgEvent)
}
}

View File

@ -21,7 +21,8 @@ class PresentationApp2x(val liveMeeting: LiveMeeting,
with PresentationConversionUpdatePubMsgHdlr with PresentationConversionUpdatePubMsgHdlr
with PresentationPageCountErrorPubMsgHdlr with PresentationPageCountErrorPubMsgHdlr
with PresentationPageGeneratedPubMsgHdlr with PresentationPageGeneratedPubMsgHdlr
with PresentationConversionCompletedPubMsgHdlr { with PresentationConversionCompletedPubMsgHdlr
with SyncGetPresentationInfoRespMsgHdlr {
val log = Logging(context.system, getClass) val log = Logging(context.system, getClass)

View File

@ -0,0 +1,28 @@
package org.bigbluebutton.core.apps.presentation
import org.bigbluebutton.core.OutMessageGateway
import org.bigbluebutton.common2.msgs._
import org.bigbluebutton.common2.domain.PresentationVO
trait SyncGetPresentationInfoRespMsgHdlr {
this: PresentationApp2x =>
val outGW: OutMessageGateway
def handleSyncGetPresentationInfoRespMsg(): Unit = {
log.debug("Handling SyncGetPresentationInfo")
val routing = Routing.addMsgToClientRouting(MessageTypes.DIRECT, liveMeeting.props.meetingProp.intId, "nodeJSapp")
val envelope = BbbCoreEnvelope(SyncGetPresentationInfoRespMsg.NAME, routing)
val header = BbbClientMsgHeader(SyncGetPresentationInfoRespMsg.NAME, liveMeeting.props.meetingProp.intId, "nodeJSapp")
val presVOs = getPresentationInfo().map { p =>
PresentationVO(p.id, p.name, p.current, p.pages.values.toVector, p.downloadable)
}
val body = SyncGetPresentationInfoRespMsgBody(presVOs)
val event = SyncGetPresentationInfoRespMsg(header, body)
val msgEvent = BbbCommonEnvCoreMsg(envelope, event)
outGW.send(msgEvent)
}
}

View File

@ -0,0 +1,31 @@
package org.bigbluebutton.core.apps.users
import org.bigbluebutton.core.OutMessageGateway
import org.bigbluebutton.common2.msgs._
import org.bigbluebutton.core.models.Users2x
trait SyncGetUsersMeetingRespMsgHdlr {
this: UsersApp2x =>
val outGW: OutMessageGateway
def handleSyncGetUsersMeetingRespMsg(): Unit = {
log.debug("Handling SyncGetUsersMeetingRespMsg")
val routing = Routing.addMsgToClientRouting(MessageTypes.DIRECT, liveMeeting.props.meetingProp.intId, "nodeJSapp")
val envelope = BbbCoreEnvelope(SyncGetUsersMeetingRespMsg.NAME, routing)
val header = BbbClientMsgHeader(SyncGetUsersMeetingRespMsg.NAME, liveMeeting.props.meetingProp.intId, "nodeJSapp")
val users = Users2x.findAll(liveMeeting.users2x)
val webUsers = users.map { u =>
WebUser(intId = u.intId, extId = u.extId, name = u.name, role = u.role,
guest = u.guest, authed = u.authed, waitingForAcceptance = u.waitingForAcceptance, emoji = u.emoji,
locked = u.locked, presenter = u.presenter, avatar = u.avatar)
}
val body = SyncGetUsersMeetingRespMsgBody(webUsers)
val event = SyncGetUsersMeetingRespMsg(header, body)
val msgEvent = BbbCommonEnvCoreMsg(envelope, event)
outGW.send(msgEvent)
}
}

View File

@ -8,6 +8,7 @@ import org.bigbluebutton.core.running.LiveMeeting
class UsersApp2x(val liveMeeting: LiveMeeting, class UsersApp2x(val liveMeeting: LiveMeeting,
val outGW: OutMessageGateway)(implicit val context: ActorContext) val outGW: OutMessageGateway)(implicit val context: ActorContext)
extends ChangeUserRoleHdlr extends ChangeUserRoleHdlr
with SyncGetUsersMeetingRespMsgHdlr
with EjectUserFromMeetingHdlr { with EjectUserFromMeetingHdlr {
val log = Logging(context.system, getClass) val log = Logging(context.system, getClass)

View File

@ -75,6 +75,13 @@ class ReceivedJsonMsgHandlerActor(
} yield { } yield {
send(m.header.userId, envelope, m) send(m.header.userId, envelope, m)
} }
case GetAllMeetingsReqMsg.NAME =>
// for {
// m <- deserialize[GetAllMeetingsReqMsg](jsonNode)
// } yield {
route[GetAllMeetingsReqMsg](meetingManagerChannel, envelope, jsonNode)
// }
case StartCustomPollReqMsg.NAME => case StartCustomPollReqMsg.NAME =>
for { for {
m <- deserialize[StartCustomPollReqMsg](jsonNode) m <- deserialize[StartCustomPollReqMsg](jsonNode)

View File

@ -27,6 +27,7 @@ import scala.concurrent.duration._
import org.bigbluebutton.core.models.BreakoutRooms import org.bigbluebutton.core.models.BreakoutRooms
import org.bigbluebutton.core2.testdata.FakeTestData import org.bigbluebutton.core2.testdata.FakeTestData
import org.bigbluebutton.core.apps.layout.LayoutApp2x import org.bigbluebutton.core.apps.layout.LayoutApp2x
import org.bigbluebutton.core.apps.meeting.SyncGetMeetingInfoRespMsgHdlr
object MeetingActor { object MeetingActor {
def props(props: DefaultProps, def props(props: DefaultProps,
@ -69,6 +70,7 @@ class MeetingActor(val props: DefaultProps,
with BreakoutRoomEndedMsgHdlr with BreakoutRoomEndedMsgHdlr
with BreakoutRoomUsersUpdateMsgHdlr with BreakoutRoomUsersUpdateMsgHdlr
with SendBreakoutUsersUpdateMsgHdlr with SendBreakoutUsersUpdateMsgHdlr
with SyncGetMeetingInfoRespMsgHdlr
with TransferUserToMeetingRequestHdlr with TransferUserToMeetingRequestHdlr
with UserMutedInVoiceConfEvtMsgHdlr with UserMutedInVoiceConfEvtMsgHdlr
with UserTalkingInVoiceConfEvtMsgHdlr { with UserTalkingInVoiceConfEvtMsgHdlr {
@ -110,6 +112,7 @@ class MeetingActor(val props: DefaultProps,
// 2x messages // 2x messages
case msg: BbbCommonEnvCoreMsg => handleBbbCommonEnvCoreMsg(msg) case msg: BbbCommonEnvCoreMsg => handleBbbCommonEnvCoreMsg(msg)
case msg: RegisterUserReqMsg => handleRegisterUserReqMsg(msg) case msg: RegisterUserReqMsg => handleRegisterUserReqMsg(msg)
case m: GetAllMeetingsReqMsg => handleGetAllMeetingsReqMsg(m)
//====================================== //======================================
@ -270,6 +273,21 @@ class MeetingActor(val props: DefaultProps,
} }
} }
def handleGetAllMeetingsReqMsg(msg: GetAllMeetingsReqMsg): Unit = {
// sync all meetings
handleSyncGetMeetingInfoRespMsg(liveMeeting.props)
// sync all users
usersApp2x.handleSyncGetUsersMeetingRespMsg()
// sync all presentations
presentationApp2x.handleSyncGetPresentationInfoRespMsg()
// TODO send all chat
// TODO send all lock settings
// TODO send all screen sharing info
}
def handleDeskShareRTMPBroadcastStoppedRequest(msg: DeskShareRTMPBroadcastStoppedRequest): Unit = { def handleDeskShareRTMPBroadcastStoppedRequest(msg: DeskShareRTMPBroadcastStoppedRequest): Unit = {
log.info("handleDeskShareRTMPBroadcastStoppedRequest: isBroadcastingRTMP=" + log.info("handleDeskShareRTMPBroadcastStoppedRequest: isBroadcastingRTMP=" +
MeetingStatus2x.isBroadcastingRTMP(liveMeeting.status) + " URL:" + MeetingStatus2x.isBroadcastingRTMP(liveMeeting.status) + " URL:" +

View File

@ -2,7 +2,7 @@ package org.bigbluebutton.core2
import akka.actor.{ Actor, ActorLogging, Props } import akka.actor.{ Actor, ActorLogging, Props }
import org.bigbluebutton.SystemConfiguration import org.bigbluebutton.SystemConfiguration
import org.bigbluebutton.common2.msgs.BbbCommonEnvCoreMsg import org.bigbluebutton.common2.msgs.{ BbbCommonEnvCoreMsg, SyncGetMeetingInfoRespMsg, SyncGetPresentationInfoRespMsg, SyncGetUsersMeetingRespMsg }
import org.bigbluebutton.common2.util.JsonUtil import org.bigbluebutton.common2.util.JsonUtil
import org.bigbluebutton.core.MessageSender import org.bigbluebutton.core.MessageSender
@ -20,6 +20,12 @@ class FromAkkaAppsMsgSenderActor(msgSender: MessageSender)
def handleBbbCommonEnvCoreMsg(msg: BbbCommonEnvCoreMsg): Unit = { def handleBbbCommonEnvCoreMsg(msg: BbbCommonEnvCoreMsg): Unit = {
val json = JsonUtil.toJson(msg) val json = JsonUtil.toJson(msg)
msgSender.send(fromAkkaAppsRedisChannel, json)
msg.envelope.name match {
case SyncGetPresentationInfoRespMsg.NAME => msgSender.send(toHTML5RedisChannel, json)
case SyncGetMeetingInfoRespMsg.NAME => msgSender.send(toHTML5RedisChannel, json)
case SyncGetUsersMeetingRespMsg.NAME => msgSender.send(toHTML5RedisChannel, json)
case _ => msgSender.send(fromAkkaAppsRedisChannel, json)
}
} }
} }

View File

@ -66,6 +66,10 @@ import org.bigbluebutton.common2.domain.PresentationVO
case class GetPresentationInfoRespMsg(header: BbbClientMsgHeader, body: GetPresentationInfoRespMsgBody) extends BbbCoreMsg case class GetPresentationInfoRespMsg(header: BbbClientMsgHeader, body: GetPresentationInfoRespMsgBody) extends BbbCoreMsg
case class GetPresentationInfoRespMsgBody(presentations: Vector[PresentationVO]) case class GetPresentationInfoRespMsgBody(presentations: Vector[PresentationVO])
object SyncGetPresentationInfoRespMsg { val NAME = "SyncGetPresentationInfoRespMsg"}
case class SyncGetPresentationInfoRespMsg(header: BbbClientMsgHeader, body: SyncGetPresentationInfoRespMsgBody) extends BbbCoreMsg
case class SyncGetPresentationInfoRespMsgBody(presentations: Vector[PresentationVO])
object SetCurrentPageEvtMsg { val NAME = "SetCurrentPageEvtMsg"} object SetCurrentPageEvtMsg { val NAME = "SetCurrentPageEvtMsg"}
case class SetCurrentPageEvtMsg(header: BbbClientMsgHeader, body: SetCurrentPageEvtMsgBody) extends BbbCoreMsg case class SetCurrentPageEvtMsg(header: BbbClientMsgHeader, body: SetCurrentPageEvtMsgBody) extends BbbCoreMsg
case class SetCurrentPageEvtMsgBody(presentationId: String, pageId: String) case class SetCurrentPageEvtMsgBody(presentationId: String, pageId: String)

View File

@ -3,19 +3,30 @@ package org.bigbluebutton.common2.msgs
import org.bigbluebutton.common2.domain.DefaultProps import org.bigbluebutton.common2.domain.DefaultProps
/** Request Messages **/
object CreateMeetingReqMsg { val NAME = "CreateMeetingReqMsg" } object CreateMeetingReqMsg { val NAME = "CreateMeetingReqMsg" }
case class CreateMeetingReqMsg(header: BbbCoreBaseHeader, case class CreateMeetingReqMsg(header: BbbCoreBaseHeader,
body: CreateMeetingReqMsgBody) extends BbbCoreMsg body: CreateMeetingReqMsgBody) extends BbbCoreMsg
case class CreateMeetingReqMsgBody(props: DefaultProps) case class CreateMeetingReqMsgBody(props: DefaultProps)
object GetAllMeetingsReqMsg { val NAME = "GetAllMeetingsReqMsg" }
case class GetAllMeetingsReqMsg(header: BbbCoreBaseHeader,
body: GetAllMeetingsReqMsgBody) extends BbbCoreMsg
case class GetAllMeetingsReqMsgBody(requesterId: String)
/** Response Messages **/
object MeetingCreatedEvtMsg { val NAME = "MeetingCreatedEvtMsg"} object MeetingCreatedEvtMsg { val NAME = "MeetingCreatedEvtMsg"}
case class MeetingCreatedEvtMsg(header: BbbCoreBaseHeader, case class MeetingCreatedEvtMsg(header: BbbCoreBaseHeader,
body: MeetingCreatedEvtBody) extends BbbCoreMsg body: MeetingCreatedEvtBody) extends BbbCoreMsg
case class MeetingCreatedEvtBody(props: DefaultProps) case class MeetingCreatedEvtBody(props: DefaultProps)
object SyncGetMeetingInfoRespMsg { val NAME = "SyncGetMeetingInfoRespMsg"}
case class SyncGetMeetingInfoRespMsg(header: BbbCoreBaseHeader,
body: SyncGetMeetingInfoRespMsgBody) extends BbbCoreMsg
case class SyncGetMeetingInfoRespMsgBody(props: DefaultProps)
/** System Messages **/ /** System Messages **/

View File

@ -119,6 +119,10 @@ object GetUsersMeetingRespMsg {
} }
object SyncGetUsersMeetingRespMsg { val NAME = "SyncGetUsersMeetingRespMsg"}
case class SyncGetUsersMeetingRespMsg(header: BbbClientMsgHeader, body: SyncGetUsersMeetingRespMsgBody) extends BbbCoreMsg
case class SyncGetUsersMeetingRespMsgBody(users: Vector[WebUser])
case class GetUsersMeetingRespMsg(header: BbbClientMsgHeader, body: GetUsersMeetingRespMsgBody) extends BbbCoreMsg case class GetUsersMeetingRespMsg(header: BbbClientMsgHeader, body: GetUsersMeetingRespMsgBody) extends BbbCoreMsg
case class GetUsersMeetingRespMsgBody(users: Vector[WebUser]) case class GetUsersMeetingRespMsgBody(users: Vector[WebUser])

View File

@ -26,6 +26,7 @@ class RedisPubSub2x {
this.queue.reset(); this.queue.reset();
this.sub.psubscribe(this.config.channels.fromAkkaApps); // 2.0 this.sub.psubscribe(this.config.channels.fromAkkaApps); // 2.0
this.sub.psubscribe(this.config.channels.toHTML5); // 2.0
Logger.info(`Subscribed to '${this.config.channels.fromBBBApps}'`); Logger.info(`Subscribed to '${this.config.channels.fromBBBApps}'`);
} }
@ -72,6 +73,20 @@ class RedisPubSub2x {
handleSubscribe() { handleSubscribe() {
if (this.didSendRequestEvent) return; if (this.didSendRequestEvent) return;
// populate collections with pre-existing data
const REDIS_CONFIG = Meteor.settings.redis;
const CHANNEL = REDIS_CONFIG.channels.toAkkaApps;
const EVENT_NAME = 'GetAllMeetingsReqMsg';
const body = {
requesterId: "nodeJSapp",
};
const header = {
name: EVENT_NAME,
};
this.publish(CHANNEL, EVENT_NAME, "someMeetingId", body, header);
this.didSendRequestEvent = true; this.didSendRequestEvent = true;
} }

View File

@ -8,6 +8,7 @@ redis:
fromBBBUsers: 'bigbluebutton:from-bbb-apps:users' fromBBBUsers: 'bigbluebutton:from-bbb-apps:users'
fromAkkaApps: 'from-akka-apps-redis-channel' fromAkkaApps: 'from-akka-apps-redis-channel'
toAkkaApps: 'to-akka-apps-redis-channel' toAkkaApps: 'to-akka-apps-redis-channel'
toHTML5: 'to-html5-redis-channel'
toBBBApps: toBBBApps:
pattern: 'bigbluebutton:to-bbb-apps:*' pattern: 'bigbluebutton:to-bbb-apps:*'
html5: 'bigbluebutton:to-bbb-html5' html5: 'bigbluebutton:to-bbb-html5'