- try to encode out messages

This commit is contained in:
Richard Alam 2015-11-17 10:41:15 -05:00
parent 364c8299d4
commit 1e1ee72ac0
9 changed files with 169 additions and 60 deletions

View File

@ -22,6 +22,7 @@ import org.bigbluebutton.core.service.recorder.RedisDispatcher
import org.bigbluebutton.core.service.recorder.RecorderApplication import org.bigbluebutton.core.service.recorder.RecorderApplication
import org.bigbluebutton.core.recorders.VoiceEventRecorder import org.bigbluebutton.core.recorders.VoiceEventRecorder
import org.bigbluebutton.core.bus._ import org.bigbluebutton.core.bus._
import org.bigbluebutton.core.JsonMessageSenderActor
object Boot extends App with SystemConfiguration { object Boot extends App with SystemConfiguration {
@ -43,9 +44,11 @@ object Boot extends App with SystemConfiguration {
val messageSenderActor = system.actorOf(MessageSenderActor.props(msgSender), "messageSenderActor") val messageSenderActor = system.actorOf(MessageSenderActor.props(msgSender), "messageSenderActor")
val recorderActor = system.actorOf(RecorderActor.props(recorderApp), "recorderActor") val recorderActor = system.actorOf(RecorderActor.props(recorderApp), "recorderActor")
val newMessageSenderActor = system.actorOf(JsonMessageSenderActor.props(msgSender), "newMessageSenderActor")
outgoingEventBus.subscribe(messageSenderActor, "outgoingMessageChannel") outgoingEventBus.subscribe(messageSenderActor, "outgoingMessageChannel")
outgoingEventBus.subscribe(recorderActor, "outgoingMessageChannel") outgoingEventBus.subscribe(recorderActor, "outgoingMessageChannel")
outgoingEventBus.subscribe(newMessageSenderActor, "outgoingMessageChannel")
val voiceEventRecorder = new VoiceEventRecorder(recorderApp) val voiceEventRecorder = new VoiceEventRecorder(recorderApp)
val bbbInGW = new BigBlueButtonInGW(system, eventBus, outGW) val bbbInGW = new BigBlueButtonInGW(system, eventBus, outGW)

View File

@ -92,7 +92,7 @@ class BigBlueButtonInGW(
} }
} }
def handleCreateBreakoutRoomsRequest(msg: HeaderAndJsonPayload) { def handleCreateBreakoutRoomsRequest(msg: InHeaderAndJsonPayload) {
// val xjson = msg.jsonMessage // val xjson = msg.jsonMessage
// //
// eventBus.publish( // eventBus.publish(

View File

@ -10,10 +10,10 @@ object JsonMessageDecoder {
import org.bigbluebutton.core.UserMessagesProtocol._ import org.bigbluebutton.core.UserMessagesProtocol._
import spray.json._ import spray.json._
def header(msg: JsObject): MessageHeader = { def header(msg: JsObject): InMessageHeader = {
msg.fields.get("header") match { msg.fields.get("header") match {
case Some(header) => case Some(header) =>
header.convertTo[MessageHeader] header.convertTo[InMessageHeader]
case None => case None =>
throw MessageProcessException("Cannot get payload information: [" + msg + "]") throw MessageProcessException("Cannot get payload information: [" + msg + "]")
} }
@ -43,7 +43,7 @@ object JsonMessageDecoder {
jsonObj <- Try(toJsObject(jsonMsg)) jsonObj <- Try(toJsObject(jsonMsg))
header <- Try(header(jsonObj)) header <- Try(header(jsonObj))
payload <- Try(payload(jsonObj)) payload <- Try(payload(jsonObj))
msg = HeaderAndJsonPayload(header, payload) msg = InHeaderAndJsonPayload(header, payload)
inmsg <- Try(convertMessage(msg)) inmsg <- Try(convertMessage(msg))
} yield inmsg } yield inmsg
} }
@ -55,7 +55,7 @@ object JsonMessageDecoder {
} }
} }
def convertMessage(msg: HeaderAndJsonPayload): InMessage = { def convertMessage(msg: InHeaderAndJsonPayload): InMessage = {
msg.header.name match { msg.header.name match {
case CreateBreakoutRoomsRequest.NAME => { case CreateBreakoutRoomsRequest.NAME => {
msg.payload.convertTo[CreateBreakoutRooms] msg.payload.convertTo[CreateBreakoutRooms]

View File

@ -0,0 +1,97 @@
package org.bigbluebutton.core
import akka.actor.Actor
import akka.actor.ActorRef
import akka.actor.ActorLogging
import akka.actor.Props
import org.bigbluebutton.core.api._
import org.bigbluebutton.common.messages.MessagingConstants
import org.bigbluebutton.core.pubsub.senders.ChatMessageToJsonConverter
import org.bigbluebutton.common.messages.StartRecordingVoiceConfRequestMessage
import org.bigbluebutton.common.messages.StopRecordingVoiceConfRequestMessage
import org.bigbluebutton.core.pubsub.senders.MeetingMessageToJsonConverter
import org.bigbluebutton.core.pubsub.senders.PesentationMessageToJsonConverter
import org.bigbluebutton.common.messages.GetPresentationInfoReplyMessage
import org.bigbluebutton.common.messages.PresentationRemovedMessage
import org.bigbluebutton.core.apps.Page
import collection.JavaConverters._
import scala.collection.JavaConversions._
import org.bigbluebutton.core.apps.SimplePollResultOutVO
import org.bigbluebutton.core.apps.SimplePollOutVO
import org.bigbluebutton.core.pubsub.senders.UsersMessageToJsonConverter
import org.bigbluebutton.common.messages.GetUsersFromVoiceConfRequestMessage
import org.bigbluebutton.common.messages.MuteUserInVoiceConfRequestMessage
import org.bigbluebutton.common.messages.EjectUserFromVoiceConfRequestMessage
import org.bigbluebutton.common.messages.GetCurrentLayoutReplyMessage
import org.bigbluebutton.common.messages.BroadcastLayoutMessage
import org.bigbluebutton.common.messages.LockLayoutMessage
import org.bigbluebutton.core.pubsub.senders.WhiteboardMessageToJsonConverter
import org.bigbluebutton.common.converters.ToJsonEncoder
import org.bigbluebutton.messages.payload.BreakoutRoomPayload
import org.bigbluebutton.messages.BreakoutRoomStarted
import org.bigbluebutton.messages.payload.CreateBreakoutRoomRequestPayload
import org.bigbluebutton.messages.CreateBreakoutRoomRequest
import org.bigbluebutton.messages.payload.BreakoutRoomJoinURLPayload
import org.bigbluebutton.messages.BreakoutRoomJoinURL
import org.bigbluebutton.messages.payload.UpdateBreakoutUsersPayload
import org.bigbluebutton.messages.payload.BreakoutUserPayload
import org.bigbluebutton.messages.UpdateBreakoutUsers
import org.bigbluebutton.messages.payload.MeetingTimeRemainingPayload
import org.bigbluebutton.messages.TimeRemainingUpdate
object JsonMessageSenderActor {
def props(msgSender: MessageSender): Props =
Props(classOf[JsonMessageSenderActor], msgSender)
}
class JsonMessageSenderActor(val service: MessageSender)
extends Actor with ActorLogging {
def receive = {
// Breakout
case msg: CreateBreakoutRoom => handleCreateBreakoutRoom(msg)
case msg: BreakoutRoomJoinURLOutMessage => handleBreakoutRoomJoinURL(msg)
case msg: BreakoutRoomStartedOutMessage => handleBreakoutRoomStarted(msg)
case msg: UpdateBreakoutUsersOutMessage => handleUpdateBreakoutUsers(msg)
case msg: MeetingTimeRemainingUpdate => handleMeetingTimeRemainingUpdate(msg)
case _ => // do nothing
}
// Breakout
private def handleBreakoutRoomStarted(msg: BreakoutRoomStartedOutMessage) {
val payload = new BreakoutRoomPayload(msg.breakout.breakoutId, msg.breakout.name)
val request = new BreakoutRoomStarted(payload)
service.send(MessagingConstants.FROM_MEETING_CHANNEL, request.toJson)
}
private def handleUpdateBreakoutUsers(msg: UpdateBreakoutUsersOutMessage) {
val users = new java.util.ArrayList[BreakoutUserPayload]()
msg.users.foreach(x => users.add(new BreakoutUserPayload(x.id, x.name)))
val payload = new UpdateBreakoutUsersPayload(msg.meetingID, msg.breakoutId, users)
val request = new UpdateBreakoutUsers(payload)
service.send(MessagingConstants.FROM_MEETING_CHANNEL, request.toJson())
}
private def handleMeetingTimeRemainingUpdate(msg: MeetingTimeRemainingUpdate) {
val payload = new MeetingTimeRemainingPayload(msg.meetingID, msg.timeRemaining)
val request = new TimeRemainingUpdate(payload)
service.send(MessagingConstants.FROM_MEETING_CHANNEL, request.toJson())
}
private def handleCreateBreakoutRoom(msg: CreateBreakoutRoom) {
val payload = new CreateBreakoutRoomRequestPayload(msg.room.breakoutId, msg.room.parentId, msg.room.name,
msg.room.voiceConfId, msg.room.viewerPassword, msg.room.moderatorPassword,
msg.room.durationInMinutes, msg.room.defaultPresentationURL)
val request = new CreateBreakoutRoomRequest(payload)
service.send(MessagingConstants.FROM_MEETING_CHANNEL, request.toJson())
}
def handleBreakoutRoomJoinURL(msg: BreakoutRoomJoinURLOutMessage) {
val payload = new BreakoutRoomJoinURLPayload(msg.meetingID,
msg.breakoutId, msg.userId, msg.joinURL)
val request = new BreakoutRoomJoinURL(payload)
service.send(MessagingConstants.FROM_MEETING_CHANNEL, request.toJson)
}
}

View File

@ -123,52 +123,10 @@ class MessageSenderActor(val service: MessageSender)
case msg: UndoWhiteboardEvent => handleUndoWhiteboardEvent(msg) case msg: UndoWhiteboardEvent => handleUndoWhiteboardEvent(msg)
case msg: WhiteboardEnabledEvent => handleWhiteboardEnabledEvent(msg) case msg: WhiteboardEnabledEvent => handleWhiteboardEnabledEvent(msg)
case msg: IsWhiteboardEnabledReply => handleIsWhiteboardEnabledReply(msg) case msg: IsWhiteboardEnabledReply => handleIsWhiteboardEnabledReply(msg)
// Breakout
case msg: CreateBreakoutRoom => handleCreateBreakoutRoom(msg)
case msg: BreakoutRoomJoinURLOutMessage => handleBreakoutRoomJoinURL(msg)
case msg: BreakoutRoomStartedOutMessage => handleBreakoutRoomStarted(msg)
case msg: UpdateBreakoutUsersOutMessage => handleUpdateBreakoutUsers(msg)
case msg: MeetingTimeRemainingUpdate => handleMeetingTimeRemainingUpdate(msg)
case _ => // do nothing case _ => // do nothing
} }
// Breakout
private def handleBreakoutRoomStarted(msg: BreakoutRoomStartedOutMessage) {
val payload = new BreakoutRoomPayload(msg.breakout.breakoutId, msg.breakout.name)
val request = new BreakoutRoomStarted(payload)
service.send(MessagingConstants.FROM_MEETING_CHANNEL, request.toJson)
}
private def handleUpdateBreakoutUsers(msg: UpdateBreakoutUsersOutMessage) {
val users = new java.util.ArrayList[BreakoutUserPayload]()
msg.users.foreach(x => users.add(new BreakoutUserPayload(x.id, x.name)))
val payload = new UpdateBreakoutUsersPayload(msg.meetingID, msg.breakoutId, users)
val request = new UpdateBreakoutUsers(payload)
service.send(MessagingConstants.FROM_MEETING_CHANNEL, request.toJson())
}
private def handleMeetingTimeRemainingUpdate(msg: MeetingTimeRemainingUpdate) {
val payload = new MeetingTimeRemainingPayload(msg.meetingID, msg.timeRemaining)
val request = new TimeRemainingUpdate(payload)
service.send(MessagingConstants.FROM_MEETING_CHANNEL, request.toJson())
}
private def handleCreateBreakoutRoom(msg: CreateBreakoutRoom) {
val payload = new CreateBreakoutRoomRequestPayload(msg.room.breakoutId, msg.room.parentId, msg.room.name,
msg.room.voiceConfId, msg.room.viewerPassword, msg.room.moderatorPassword,
msg.room.durationInMinutes, msg.room.defaultPresentationURL)
val request = new CreateBreakoutRoomRequest(payload)
service.send(MessagingConstants.FROM_MEETING_CHANNEL, request.toJson())
}
def handleBreakoutRoomJoinURL(msg: BreakoutRoomJoinURLOutMessage) {
val payload = new BreakoutRoomJoinURLPayload(msg.meetingID,
msg.breakoutId, msg.userId, msg.joinURL)
val request = new BreakoutRoomJoinURL(payload)
service.send(MessagingConstants.FROM_MEETING_CHANNEL, request.toJson)
}
private def handleGetChatHistoryReply(msg: GetChatHistoryReply) { private def handleGetChatHistoryReply(msg: GetChatHistoryReply) {
val json = ChatMessageToJsonConverter.getChatHistoryReplyToJson(msg) val json = ChatMessageToJsonConverter.getChatHistoryReplyToJson(msg)

View File

@ -3,10 +3,40 @@ package org.bigbluebutton.core
import spray.json.{ DefaultJsonProtocol, JsValue, JsString, DeserializationException, JsonFormat } import spray.json.{ DefaultJsonProtocol, JsValue, JsString, DeserializationException, JsonFormat }
import org.bigbluebutton.core.api.BreakoutRoomInPayload import org.bigbluebutton.core.api.BreakoutRoomInPayload
import org.bigbluebutton.core.api.CreateBreakoutRooms import org.bigbluebutton.core.api.CreateBreakoutRooms
import org.bigbluebutton.core.api.MessageHeader import org.bigbluebutton.core.api.InMessageHeader
import org.bigbluebutton.core.OutMessagePayload
object UserMessagesProtocol extends DefaultJsonProtocol { object UserMessagesProtocol extends DefaultJsonProtocol {
/*
implicit object RoleJsonFormat extends JsonFormat[Role.RoleType] {
def write(obj: Role.RoleType): JsValue = JsString(obj.toString)
def read(json: JsValue): Role.RoleType = json match {
case JsString(str) => Role.withName(str)
case _ => throw new DeserializationException("Enum string expected")
}
}
*/
implicit object MessageTypeFormat extends JsonFormat[MessageType.MessageType] {
def write(obj: MessageType.MessageType): JsValue = JsString(obj.toString)
def read(json: JsValue): MessageType.MessageType = json match {
case JsString(str) => MessageType.withName(str)
case _ => throw new DeserializationException("Enum string expected")
}
}
implicit val breakoutRoomInPayloadFormat = jsonFormat2(BreakoutRoomInPayload) implicit val breakoutRoomInPayloadFormat = jsonFormat2(BreakoutRoomInPayload)
implicit val CreateBreakoutRoomsFormat = jsonFormat3(CreateBreakoutRooms) implicit val createBreakoutRoomsFormat = jsonFormat3(CreateBreakoutRooms)
implicit val msgHeaderFormat = jsonFormat1(MessageHeader) implicit val inMsgHeaderFormat = jsonFormat1(InMessageHeader)
implicit val outMessageEnvelopeHeaderFormat = jsonFormat2(OutMessageEnvelopeHeader)
implicit val outMessageEnvelopePayloadFormat = jsonFormat1(OutMessageEnvelopePayload)
implicit val outMessagePayloadFormat = jsonFormat2(OutMessagePayload)
implicit val outMessageHeaderFormat = jsonFormat1(OutMessageHeader)
case class OutMessageEnvelopePayload(payload: OutMessagePayload)
case class OutMessageEnvelope(header: OutMessageEnvelopeHeader, payload: OutMessageEnvelopePayload)
case class OutMessagePayload(header: OutMessageHeader, payload: OutMessage)
case class OutMessageHeader(name: String)
} }

View File

@ -0,0 +1,22 @@
package org.bigbluebutton.core
object MessageType extends Enumeration {
type MessageType = Value
val SYSTEM = Value("system")
val BROADCAST = Value("broadcast")
val DIRECT = Value("direct")
}
case class OutMessageEnvelopeHeader(messageType: MessageType.MessageType, destinationAddress: String)
case class OutMessageEnvelopePayload(payload: OutMessagePayload)
case class OutMessageEnvelope(header: OutMessageEnvelopeHeader, payload: OutMessageEnvelopePayload)
case class OutMessagePayload(header: OutMessageHeader, payload: OutMessage)
case class OutMessageHeader(name: String)
trait OutMessage
case class CreateBreakoutRoomRequest(meetingId: String, room: CreateBreakoutRoomOutPayload) extends OutMessage
case class CreateBreakoutRoomOutPayload(breakoutId: String, name: String, parentId: String,
voiceConfId: String, durationInMinutes: Int,
moderatorPassword: String, viewerPassword: String,
defaultPresentationUrl: String

View File

@ -7,8 +7,8 @@ import org.bigbluebutton.core.MeetingProperties
import org.bigbluebutton.core.apps.BreakoutUser import org.bigbluebutton.core.apps.BreakoutUser
import spray.json.JsObject import spray.json.JsObject
case class MessageHeader(name: String) case class InMessageHeader(name: String)
case class HeaderAndJsonPayload(header: MessageHeader, payload: JsObject) case class InHeaderAndJsonPayload(header: InMessageHeader, payload: JsObject)
case class MessageProcessException(message: String) extends Exception(message) case class MessageProcessException(message: String) extends Exception(message)
trait InMessage trait InMessage

View File

@ -10,7 +10,6 @@ import org.bigbluebutton.core.apps.SimplePollOutVO
import org.bigbluebutton.core.apps.SimplePollResultOutVO import org.bigbluebutton.core.apps.SimplePollResultOutVO
import org.bigbluebutton.core.apps.BreakoutUser import org.bigbluebutton.core.apps.BreakoutUser
abstract class OutMessage
case class VoiceRecordingStarted(meetingID: String, recorded: Boolean, recordingFile: String, timestamp: String, confNum: String) extends IOutMessage case class VoiceRecordingStarted(meetingID: String, recorded: Boolean, recordingFile: String, timestamp: String, confNum: String) extends IOutMessage
case class VoiceRecordingStopped(meetingID: String, recorded: Boolean, recordingFile: String, timestamp: String, confNum: String) extends IOutMessage case class VoiceRecordingStopped(meetingID: String, recorded: Boolean, recordingFile: String, timestamp: String, confNum: String) extends IOutMessage
@ -30,15 +29,15 @@ case class PubSubPong(system: String, timestamp: Long) extends IOutMessage
case object IsAliveMessage extends IOutMessage case object IsAliveMessage extends IOutMessage
// Breakout Rooms // Breakout Rooms
case class CreateBreakoutRoom(meetingID: String, recorded: Boolean, room: BreakoutRoomOutPayload) extends IOutMessage case class CreateBreakoutRoom(meetingId: String, recorded: Boolean, room: BreakoutRoomOutPayload) extends IOutMessage
case class BreakoutRoomOutPayload(breakoutId: String, name: String, parentId: String, case class BreakoutRoomOutPayload(breakoutId: String, name: String, parentId: String,
voiceConfId: String, durationInMinutes: Int, moderatorPassword: String, viewerPassword: String, voiceConfId: String, durationInMinutes: Int, moderatorPassword: String, viewerPassword: String,
defaultPresentationURL: String) defaultPresentationURL: String)
case class BreakoutRoomJoinURLOutMessage(meetingID: String, recorded: Boolean, breakoutId: String, userId: String, joinURL: String) extends IOutMessage case class BreakoutRoomJoinURLOutMessage(meetingId: String, recorded: Boolean, breakoutId: String, userId: String, joinURL: String) extends IOutMessage
case class BreakoutRoomStartedOutMessage(meetingID: String, recorded: Boolean, breakout: BreakoutRoomBody) extends IOutMessage case class BreakoutRoomStartedOutMessage(meetingId: String, recorded: Boolean, breakout: BreakoutRoomBody) extends IOutMessage
case class BreakoutRoomBody(name: String, breakoutId: String) case class BreakoutRoomBody(name: String, breakoutId: String)
case class UpdateBreakoutUsersOutMessage(meetingID: String, recorded: Boolean, breakoutId: String, users: Vector[BreakoutUser]) extends IOutMessage case class UpdateBreakoutUsersOutMessage(meetingId: String, recorded: Boolean, breakoutId: String, users: Vector[BreakoutUser]) extends IOutMessage
case class MeetingTimeRemainingUpdate(meetingID: String, recorded: Boolean, timeRemaining: Int) extends IOutMessage case class MeetingTimeRemainingUpdate(meetingId: String, recorded: Boolean, timeRemaining: Int) extends IOutMessage
// Permissions // Permissions
case class PermissionsSettingInitialized(meetingID: String, permissions: Permissions, applyTo: Array[UserVO]) extends IOutMessage case class PermissionsSettingInitialized(meetingID: String, permissions: Permissions, applyTo: Array[UserVO]) extends IOutMessage