- start refactoring meetings in bbb-web

This commit is contained in:
Richard Alam 2017-05-18 12:43:29 -07:00
parent d1779d9948
commit 0c827a7d49
9 changed files with 180 additions and 67 deletions

View File

@ -1,14 +1,10 @@
package org.bigbluebutton.api2;
import org.bigbluebutton.api.domain.Meeting;
import org.bigbluebutton.api.domain.Recording;
import org.bigbluebutton.api.domain.RecordingMetadata;
import org.bigbluebutton.api.domain.UserSession;
import org.bigbluebutton.api.messaging.messages.*;
import org.bigbluebutton.api2.domain.ConfigProps;
import java.util.Collection;
import java.util.List;
import java.util.Map;
public interface IMeetingService {

View File

@ -1,8 +1,6 @@
package org.bigbluebutton.api2.domain;
import org.bigbluebutton.api.domain.User;
import java.util.Map;
public class UsersProp2 {
@ -10,16 +8,16 @@ public class UsersProp2 {
public final boolean userHasJoined;
public final boolean webcamsOnlyForModerator;
public final int maxUsers;
public final Map<String, Object> userCustomData;
public final Map<String, User> users;
public final Map<String, String> userCustomData;
public final Map<String, User2> users;
public final Map<String, Long> registeredUsers;
public UsersProp2(int maxUsers,
boolean webcamsOnlyForModerator,
String guestPolicy,
boolean userHasJoined,
Map<String, Object> userCustomData,
Map<String, User> users,
Map<String, String> userCustomData,
Map<String, User2> users,
Map<String, Long> registeredUsers) {
this.maxUsers = maxUsers;
this.webcamsOnlyForModerator = webcamsOnlyForModerator;

View File

@ -1,38 +1,23 @@
package org.bigbluebutton.api2.domain
import org.bigbluebutton.api.domain.{Config, User}
import org.bigbluebutton.api.domain.{Config}
case class ConfigProps(defaultConfigToken: String,
configs: collection.immutable.Map[String, Config])
case class DurationProps(duration: Int,
createdTime: Long,
startTime: Long,
endTime: Long)
case class MeetingProp(name: String,
extId: String,
intId: String,
parentId: String,
sequence: Int,
isBreakout: Boolean)
case class PasswordProp(moderatorPass: String,
viewerPass: String)
case class RecordProp(record: Boolean,
autoStartRecording: Boolean,
allowStartStopRecording: Boolean)
case class WelcomeProp(welcomeMsgTemplate: String,
welcomeMsg: String,
modOnlyMessage: String)
case class VoiceProp(telVoice: String,
webVoice: String,
dialNumber: String)
case class UsersProp(maxUsers: Int,
webcamsOnlyForModerator: Boolean,
guestPolicy: String,
userHasJoined: Boolean,
userCustomData: collection.immutable.Map[String, String],
users: collection.immutable.Map[String, User],
registeredUsers: collection.immutable.Map[String, Long])
class MeetingProps {
case class ConfigProps(defaultConfigToken: String, configs: collection.immutable.Map[String, Config])
}
case class DurationProps(duration: Int, createdTime: Long, startTime: Long, endTime: Long)
case class MeetingProp(name: String, extId: String, intId: String, parentId: String, sequence: Int, isBreakout: Boolean)
case class PasswordProp(moderatorPass: String, viewerPass: String)
case class RecordProp(record: Boolean, autoStartRecording: Boolean, allowStartStopRecording: Boolean)
case class WelcomeProp(welcomeMsgTemplate: String, welcomeMsg: String, modOnlyMessage: String)
case class VoiceProp(telVoice: String, webVoice: String, dialNumber: String)
case class UsersProp(maxUsers: Int, webcamsOnlyForModerator: Boolean, guestPolicy: String, userHasJoined: Boolean)
case class Meeting2(meetingProp: MeetingProp, durationProps: DurationProps, password: PasswordProp,
recordProp: RecordProp, welcomeProp: WelcomeProp, voiceProp: VoiceProp, usersProp: UsersProp)

View File

@ -0,0 +1,94 @@
package org.bigbluebutton.api2.domain
case class User2(intId: String, extId: String, name: String, role: String, avatarURL: String,
guest: Boolean, waitingForAcceptance: Boolean, status: Vector[String],
streams: Set[String])
object Users {
def findWithId(users: Users, id: String): Option[User2] = {
users.toVector.find(u => u.intId == id)
}
def add(users: Users, user: User2): User2 = {
users.save(user)
}
def remove(users: Users, id: String): Option[User2] = {
users.remove(id)
}
}
class Users {
private var users = new collection.immutable.HashMap[String, User2]
private def toVector: Vector[User2] = users.values.toVector
private def save(user: User2): User2 = {
users += user.intId -> user
user
}
private def remove(id: String): Option[User2] = {
val user = users.get(id)
user foreach (u => users -= id)
user
}
}
case class RegisteredUser2(meetingId: String, intId: String, name: String, role: String,
extId: String, authToken: String, avatarURL: String,
guest: Boolean, authed: Boolean)
object RegisteredUsers {
def findWithId(users: RegisteredUsers, id: String): Option[RegisteredUser2] = {
users.toVector.find(u => u.intId == id)
}
def add(users: RegisteredUsers, user: RegisteredUser2): RegisteredUser2 = {
users.save(user)
}
def remove(users: RegisteredUsers, id: String): Option[RegisteredUser2] = {
users.remove(id)
}
}
class RegisteredUsers {
private var users = new collection.immutable.HashMap[String, RegisteredUser2]
private def toVector: Vector[RegisteredUser2] = users.values.toVector
private def save(user: RegisteredUser2): RegisteredUser2 = {
users += user.intId -> user
user
}
private def remove(id: String): Option[RegisteredUser2] = {
val user = users.get(id)
user foreach (u => users -= id)
user
}
}
case class Config2(token: String, timestamp: Long, config: String)
object Configs {
}
class Configs {
private var configs = new collection.immutable.HashMap[String, Config2]
private def toVector: Vector[Config2] = configs.values.toVector
private def save(config: Config2): Config2 = {
configs += config.token -> config
config
}
private def remove(id: String): Option[Config2] = {
val config = configs.get(id)
config foreach (u => configs -= id)
config
}
}

View File

@ -1,6 +1,10 @@
package org.bigbluebutton.api2.meeting
import akka.actor.{Actor, ActorLogging}
import org.bigbluebutton.api.domain.UserSession
import org.bigbluebutton.common.messages.UserJoinedVoiceMessage
object MeetingActor {
@ -12,3 +16,4 @@ class MeetingActor extends Actor with ActorLogging {
}
}

View File

@ -1,7 +1,33 @@
package org.bigbluebutton.api2.meeting
object MeetingsManager {
def findWithId(mgr: MeetingsManager, id: String): Option[RunningMeeting] = {
mgr.toVector.find(m => m.meetingId == id)
}
def add(mgr: MeetingsManager, meeting: RunningMeeting): RunningMeeting = {
mgr.save(meeting)
}
def remove(mgr: MeetingsManager, id: String): Option[RunningMeeting] = {
mgr.remove(id)
}
}
class MeetingsManager {
private var meetings = new collection.immutable.HashMap[String, RunningMeeting]
private def toVector: Vector[RunningMeeting] = meetings.values.toVector
private def save(meeting: RunningMeeting): RunningMeeting = {
meetings += meeting.meetingId -> meeting
meeting
}
private def remove(id: String): Option[RunningMeeting] = {
val meeting = meetings.get(id)
meeting foreach (u => meetings -= id)
meeting
}
}

View File

@ -1,7 +1,9 @@
package org.bigbluebutton.api2.meeting
import akka.actor.{Actor, ActorLogging, Props}
import org.bigbluebutton.api.domain.UserSession
import org.bigbluebutton.api2.bus.MsgToAkkaAppsEventBus
import org.bigbluebutton.common.messages.UserJoinedVoiceMessage
sealed trait ApiMsg
@ -15,6 +17,28 @@ case class EndBreakoutRoomMsg() extends ApiMsg
case class KeepAliveReply() extends ApiMsg
case class MeetingDestoyedMsg() extends ApiMsg
case class MeetingStartedMsg() extends ApiMsg
case class AddUserSession(token: String, session: UserSession)
case class RegisterUser(meetingId: String, intUserId: String, name: String, role: String,
extUserId: String, authToken: String, avatarURL: String,
guest: Boolean, authed: Boolean)
case class GetUserSession(token: String)
case class RemoveUserSession(token: String)
case object PurgeRegisteredUsers
case class GetMeetings()
case class GetSessions()
case class CreateMeeting(m: Meeting)
case class GetMeeting(meetingId: String)
case class GetMeetingsWithId(meetingId: String)
case class GetNotEndedMeetingWithId(meetingId: String)
case class IsMeetingWithVoiceBridgeExist(voiceBridge: String)
case class EndMeeting(meetingId: String)
case class AddUserCustomData(meetingId: String, userId: String, userCustomData: collection.immutable.Map[String, String])
case class UserJoinedVoice(msg: UserJoinedVoiceMessage)
case class UserLeftVoice(msg: UserLeftVoice)
case class UserListeningOnly(msg: UserListeningOnly)
case class UserSharedWebcam(msg: UserSharedWebcam)
case class UserUnsharedWebcam(msg: UserUnsharedWebcam)
object MeetingsManagerActor {
def props(msgToAkkaAppsEventBus: MsgToAkkaAppsEventBus): Props =
@ -24,6 +48,7 @@ object MeetingsManagerActor {
class MeetingsManagerActor(msgToAkkaAppsEventBus: MsgToAkkaAppsEventBus) extends Actor with ActorLogging {
def receive = {
case msg: CreateMeetingMsg => handleCreateMeeting(msg)
}
}

View File

@ -1,6 +1,12 @@
package org.bigbluebutton.api2.meeting
import org.bigbluebutton.api2.domain.{RegisteredUser2, User2}
class RunningMeeting {
object RunningMeeting {
}
class RunningMeeting(val meetingId: String) {
private var registeredUsers = new collection.immutable.HashMap[String, RegisteredUser2]
}

View File

@ -1,22 +0,0 @@
package org.bigbluebutton.api2.meeting
import java.util.Map
/**
* Created by ralam on 2017-05-17.
*
* private var internalUserId: String = null
* private var externalUserId: String = null
* private var fullname: String = null
* private var role: String = null
* private var avatarURL: String = null
* private var status: Map[String, String] = null
* private var guest: Boolean = false
* private var waitingForAcceptance: Boolean = false
* private var listeningOnly: Boolean = false
* private var voiceJoined: Boolean = false
* private var streams: List[String] = null
*/
case class User(internalUserId: String, externalUserId: String, fullname: String, role: String, avatarURL: String,
guest: Boolean, waitingForAcceptance: Boolean, status: collection.immutable.Map[String, String],
streams: Set[String])