Merge branch 'make-users-user-conn-invoke' of https://github.com/bigbluebutton/bigbluebutton into make-users-user-conn-invoke

Conflicts:
	bigbluebutton-web/src/java/org/bigbluebutton/api/messaging/RedisMessagingService.java
This commit is contained in:
Markos Calderon 2013-06-24 17:35:16 -05:00
commit 84a4bf5893
24 changed files with 613 additions and 204 deletions

View File

@ -0,0 +1,15 @@
package org.bigbluebutton.conference.service.poll;
public interface PollInGW {
void createPoll(String meetingID, String requesterID, String msg);
void updatePoll(String meetingID, String requesterID, String msg);
void startPoll(String meetingID, String requesterID, String msg);
void stopPoll(String meetingID, String requesterID, String msg);
void removePoll(String meetingID, String requesterID, String msg);
void respondPoll(String meetingID, String requesterID, String msg);
}

View File

@ -19,14 +19,12 @@
package org.bigbluebutton.conference.service.poll;
import org.slf4j.Logger;
import org.bigbluebutton.conference.BigBlueButtonSession;
import org.bigbluebutton.conference.Constants;
import org.bigbluebutton.core.api.IBigBlueButtonInGW;
import org.red5.logging.Red5LoggerFactory;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import org.red5.server.api.Red5;
import org.red5.server.api.scope.IScope;
public class PollService {
private static Logger log = Red5LoggerFactory.getLogger( PollService.class, "bigbluebutton" );
@ -39,31 +37,45 @@ public class PollService {
public void createPoll(String msg){
System.out.println("*** PollService:: create poll \n" + msg + "\n");
bbbInGW.createPoll(getMeetingID(), getRequestedID(), msg);
}
public void updatePoll(String msg){
System.out.println("*** PollService:: update poll \n" + msg + "\n");
bbbInGW.updatePoll(getMeetingID(), getRequestedID(), msg);
}
public void startPoll(String msg){
System.out.println("*** PollService:: start poll \n" + msg + "\n");
bbbInGW.startPoll(getMeetingID(), getRequestedID(), msg);
}
public void stopPoll(String msg){
System.out.println("*** PollService:: stop poll \n" + msg + "\n");
bbbInGW.stopPoll(getMeetingID(), getRequestedID(), msg);
}
public void removePoll(String msg){
System.out.println("*** PollService:: remove poll \n" + msg + "\n");
bbbInGW.removePoll(getMeetingID(), getRequestedID(), msg);
}
public void respondPoll(String msg){
System.out.println("*** PollService:: respond poll \n" + msg + "\n");
bbbInGW.respondPoll(getMeetingID(), getRequestedID(), msg);
}
private String getMeetingID() {
IScope scope = Red5.getConnectionLocal().getScope();
return scope.getName();
}
private String getRequestedID() {
return getBbbSession().getInternalUserID();
}
private BigBlueButtonSession getBbbSession() {
return (BigBlueButtonSession) Red5.getConnectionLocal().getAttribute(Constants.SESSION);
}
}

View File

@ -30,4 +30,11 @@ public interface IBigBlueButtonInGW {
void sharePresentation(String meetingID, String presentationID, boolean share);
void getSlideInfo(String meetingID, String requesterID);
// Polling
void createPoll(String meetingID, String requesterID, String msg);
void updatePoll(String meetingID, String requesterID, String msg);
void startPoll(String meetingID, String requesterID, String msg);
void stopPoll(String meetingID, String requesterID, String msg);
void removePoll(String meetingID, String requesterID, String msg);
void respondPoll(String meetingID, String requesterID, String msg);
}

View File

@ -23,6 +23,7 @@ import org.bigbluebutton.core.api.DestroyMeeting
import org.bigbluebutton.core.api.KeepAliveMessage
import org.bigbluebutton.core.api.PreuploadedPresentations
import scala.collection.JavaConversions._
import org.bigbluebutton.core.apps.poll.PollInGateway
class BigBlueButtonInGW(bbbGW: BigBlueButtonGateway) extends IBigBlueButtonInGW {
@ -128,4 +129,30 @@ class BigBlueButtonInGW(bbbGW: BigBlueButtonGateway) extends IBigBlueButtonInGW
bbbGW.accept(new GetSlideInfo(meetingID, requesterID))
}
// Polling
val pollGW = new PollInGateway(bbbGW)
def createPoll(meetingID: String, requesterID: String, msg: String) {
pollGW.createPoll(meetingID, requesterID, msg)
}
def updatePoll(meetingID: String, requesterID: String, msg: String) {
pollGW.updatePoll(meetingID, requesterID, msg)
}
def startPoll(meetingID: String, requesterID: String, msg: String) {
pollGW.startPoll(meetingID, requesterID, msg)
}
def stopPoll(meetingID: String, requesterID: String, msg: String) {
pollGW.stopPoll(meetingID, requesterID, msg)
}
def removePoll(meetingID: String, requesterID: String, msg: String) {
pollGW.removePoll(meetingID, requesterID, msg)
}
def respondPoll(meetingID: String, requesterID: String, msg: String) {
}
}

View File

@ -27,6 +27,7 @@ class Meeting(val meetingID: String, val recorded: Boolean, val voiceBridge: Str
case msg: InMessage => {
usersApp.handleMessage(msg)
presentationApp.handleMessage(msg)
pollApp.handleMessage(msg)
}
case StopMeetingActor => exit
}

View File

@ -1,23 +1,40 @@
package org.bigbluebutton.core.apps.poll
import scala.collection.mutable.HashMap
import QuestionType._
import scala.collection.mutable.ArrayBuffer
case class ResponseVO(id: String, text: String, responders: Array[Responder] = Array[Responder]())
case class QuestionVO(id: String, multiResponse: Boolean, question: String, responses: Array[ResponseVO])
case class PollVO(id: String, title: String, questions: Array[QuestionVO])
case class Responder(val userID: String, val name: String)
class Poll(val id: String, val title: String, val questions: Array[Question]) {
private var _active: Boolean = false
private var started: Boolean = false
private var stopped: Boolean = false
def active = _active
def activate():Unit = {
_active = true;
def start() {
started = true;
}
def deactivate():Unit = {
_active = false;
def stop() {
stopped = true;
}
def isStarted():Boolean = {
return started
}
def isStopped():Boolean = {
return stopped
}
def clear() {
questions.foreach(q => {
q.clear
})
started = false
stopped = false
}
def hasResponses():Boolean = {
@ -28,11 +45,73 @@ class Poll(val id: String, val title: String, val questions: Array[Question]) {
return false
}
def respondToQuestion(questionID: String, responseID: String, userID: String, username: String) {
def respondToQuestion(questionID: String, responseID: String, responder: Responder) {
questions.foreach(q => {
if (q.id.equals(questionID)) {
q.respondToQuestion(responseID, new Responder(userID, username))
q.respondToQuestion(responseID, responder)
}
})
}
def toPollVO():PollVO = {
val qvos = new ArrayBuffer[QuestionVO]
questions.foreach(q => {
qvos += q.toQuestionVO
})
new PollVO(id, title, qvos.toArray)
}
}
class Question(val id: String, val multiResponse: Boolean, val question: String, val responses: Array[Response]) {
def clear() {
responses.foreach(r => r.clear)
}
def hasResponders():Boolean = {
responses.foreach(r => {
if (r.numResponders > 0) return true
})
return false
}
def respondToQuestion(id: String, responder: Responder) {
responses.foreach(r => {
if (r.id == id) r.addResponder(responder)
})
}
def toQuestionVO():QuestionVO = {
val rvos = new ArrayBuffer[ResponseVO]
responses.foreach(response => {
val r = new ResponseVO(response.id, response.response, response.getResponders)
rvos += r
})
new QuestionVO(id, multiResponse, question, rvos.toArray)
}
}
class Response(val id: String, val response: String) {
val responders = new ArrayBuffer[Responder]()
def clear() {
responders.clear
}
def addResponder(responder: Responder) {
responders += responder
}
def numResponders():Int = {
responders.length;
}
def getResponders():Array[Responder] = {
var r = new Array[Responder](responders.length)
responders.copyToArray(r)
return r
}
}

View File

@ -8,7 +8,7 @@ import scala.collection.mutable.ArrayBuffer
class PollApp(meetingID: String, recorded: Boolean, outGW: MessageOutGateway) {
import org.bigbluebutton.core.apps.poll.messages._
private val polls = new HashMap[String, Poll]()
val model = new PollModel
def handleMessage(msg: InMessage):Unit = {
msg match {
@ -21,73 +21,52 @@ class PollApp(meetingID: String, recorded: Boolean, outGW: MessageOutGateway) {
case startPoll: StartPoll => handleStartPoll(startPoll)
case clearPoll: ClearPoll => handleClearPoll(clearPoll)
case getPolls: GetPolls => handleGetPolls(getPolls)
case _ => // do nothing
}
}
private def handleGetPolls(msg: GetPolls) {
val poll = new ArrayBuffer[PollVO]
polls.values.foreach(p => {
val questions = new ArrayBuffer[QuestionVO]
p.questions.foreach(q => {
val responses = new ArrayBuffer[ResponseVO]
q.responses.foreach(response => {
val r = new ResponseVO(response.id, response.response)
responses += r
})
val quest = new QuestionVO(q.id, q.multiResponse, q.question, responses.toArray)
questions += quest
})
poll += new PollVO(p.id, p.title, questions.toArray)
})
outGW.send(new GetPollsReplyOutMsg(meetingID, recorded, msg.requesterID, poll.toArray))
var polls = model.getPolls
outGW.send(new GetPollsReplyOutMsg(meetingID, recorded, msg.requesterID, polls))
}
private def handleClearPoll(msg: ClearPoll) {
polls.get(msg.pollID) match {
case None => // send poll not found message
case Some(p) => {
p.clear
outGW.send(new PollClearedOutMsg(meetingID, recorded, msg.pollID))
}
}
if (model.clearPoll(msg.pollID)) {
outGW.send(new PollClearedOutMsg(meetingID, recorded, msg.pollID))
} else {
print("PollApp:: handleClearPoll - " + msg.pollID + " not found" )
}
}
private def handleStartPoll(msg: StartPoll) {
polls.get(msg.pollID) match {
case None => // send poll not found message
case Some(p) => {
p.activate
outGW.send(new PollStartedOutMsg(meetingID, recorded, msg.pollID))
}
}
if (model.hasPoll(msg.pollID)) {
model.startPoll(msg.pollID)
outGW.send(new PollStartedOutMsg(meetingID, recorded, msg.pollID))
} else {
print("PollApp:: handleStartPoll - " + msg.pollID + " not found" )
}
}
private def handleStopPoll(msg: StopPoll) {
polls.get(msg.pollID) match {
case None => // send poll not found message
case Some(p) => {
p.deactivate
outGW.send(new PollStoppedOutMsg(meetingID, recorded, msg.pollID))
}
}
if (model.hasPoll(msg.pollID)) {
model.stopPoll(msg.pollID)
outGW.send(new PollStoppedOutMsg(meetingID, recorded, msg.pollID))
} else {
print("PollApp:: handleStopPoll - " + msg.pollID + " not found" )
}
}
private def handleSharePoll(msg: SharePoll) {
}
private def handleRemovePoll(msg: RemovePoll) {
polls.get(msg.pollID) match {
case None => // send poll not found message
case Some(p) => {
polls -= p.id
outGW.send(new PollRemovedOutMsg(meetingID, recorded, msg.pollID))
}
}
if (model.hasPoll(msg.pollID)) {
model.removePoll(msg.pollID)
outGW.send(new PollRemovedOutMsg(meetingID, recorded, msg.pollID))
} else {
print("PollApp:: handleRemovePoll - " + msg.pollID + " not found" )
}
}
private def handleDestroyPoll(msg: DestroyPoll) {
@ -95,55 +74,15 @@ class PollApp(meetingID: String, recorded: Boolean, outGW: MessageOutGateway) {
}
private def handleUpdatePoll(msg: UpdatePoll) {
polls.get(msg.poll.id) match {
case None => // send poll not found message
case Some(p) => {
val pollVO = msg.poll
val questions = new ArrayBuffer[Question]
pollVO.questions.foreach(qv => {
val responses = new ArrayBuffer[Response]
qv.responses.foreach(rv => {
val response = new Response(rv.id, rv.text)
responses += response
})
questions += new Question(qv.id, qv.multiResponse, qv.question, responses.toArray)
})
val poll = new Poll(msg.poll.id, msg.poll.title, questions.toArray)
polls += poll.id -> poll
outGW.send(new PollUpdatedOutMsg(meetingID, recorded, poll.id, pollVO))
}
}
if (model.updatePoll(msg.poll)) {
outGW.send(new PollUpdatedOutMsg(meetingID, recorded, msg.poll.id, msg.poll))
} else {
print("PollApp:: handleUpdatePoll - " + msg.poll.id + " not found" )
}
}
private def handleCreatePoll(msg: CreatePoll) {
val pollVO = msg.poll
val questions = new ArrayBuffer[Question]
pollVO.questions.foreach(qv => {
val responses = new ArrayBuffer[Response]
qv.responses.foreach(rv => {
val response = new Response(rv.id, rv.text)
responses += response
})
questions += new Question(qv.id, qv.multiResponse, qv.question, responses.toArray)
})
val poll = new Poll(msg.poll.id, msg.poll.title, questions.toArray)
polls += poll.id -> poll
outGW.send(new PollCreatedOutMsg(meetingID, recorded, poll.id, pollVO))
model.createPoll(msg.poll)
outGW.send(new PollCreatedOutMsg(meetingID, recorded, msg.poll.id, msg.poll))
}
}

View File

@ -1,8 +1,43 @@
package org.bigbluebutton.core.apps.poll
import org.bigbluebutton.conference.service.poll.PollInGW
import org.bigbluebutton.core.BigBlueButtonGateway
import org.bigbluebutton.core.apps.poll.messages.CreatePoll
import org.bigbluebutton.core.apps.poll.messages.UpdatePoll
import org.bigbluebutton.core.apps.poll.messages.StartPoll
import org.bigbluebutton.core.apps.poll.messages.StopPoll
import org.bigbluebutton.core.apps.poll.messages.RemovePoll
class PollInGateway(bbbGW: BigBlueButtonGateway) {
class PollInGateway {
val msgConverter = new PollMessageConverter
def createPoll(meetingID: String, requesterID: String, msg: String) {
val pvo = msgConverter.convertCreatePollMessage(msg)
bbbGW.accept(new CreatePoll(meetingID, requesterID, pvo))
}
def updatePoll(meetingID: String, requesterID: String, msg: String) {
val pvo = msgConverter.convertUpdatePollMessage(msg)
bbbGW.accept(new UpdatePoll(meetingID, requesterID, pvo))
}
def startPoll(meetingID: String, requesterID: String, msg: String) {
val pollID = msgConverter.convertStartPollMessage(msg)
bbbGW.accept(new StartPoll(meetingID, requesterID, pollID))
}
def stopPoll(meetingID: String, requesterID: String, msg: String) {
val pollID = msgConverter.convertStopPollMessage(msg)
bbbGW.accept(new StopPoll(meetingID, requesterID, pollID))
}
def removePoll(meetingID: String, requesterID: String, msg: String) {
val pollID = msgConverter.convertRemovePollMessage(msg)
bbbGW.accept(new RemovePoll(meetingID, requesterID, pollID))
}
def respondPoll(meetingID: String, requesterID: String, msg: String) {
}
}

View File

@ -1,10 +1,7 @@
package org.bigbluebutton.core.apps.poll
import org.bigbluebutton.core.apps.poll.messages.PollVO
import com.google.gson.Gson
import com.google.gson.JsonParser
import org.bigbluebutton.core.apps.poll.messages.QuestionVO
import org.bigbluebutton.core.apps.poll.messages.ResponseVO
import org.bigbluebutton.core.util.RandomStringGenerator._
import scala.collection.mutable.ArrayBuffer
@ -48,7 +45,10 @@ class PollMessageConverter {
i += 1
}
new PollVO(randomAlphanumericString(12), title, cvoArray.toArray)
//new PollVO(randomAlphanumericString(12), title, cvoArray.toArray)
// Hardocde for now for testing
new PollVO("pollID", title, cvoArray.toArray)
}
def convertUpdatePollMessage(msg:String):PollVO = {
@ -96,4 +96,31 @@ class PollMessageConverter {
new PollVO(pollID, title, cvoArray.toArray)
}
def convertStartPollMessage(msg: String):String = {
val gson = new Gson();
val parser = new JsonParser();
val obj = parser.parse(msg).getAsJsonObject();
val pollID = gson.fromJson(obj.get("pollID"), classOf[String]);
pollID
}
def convertStopPollMessage(msg: String):String = {
val gson = new Gson();
val parser = new JsonParser();
val obj = parser.parse(msg).getAsJsonObject();
val pollID = gson.fromJson(obj.get("pollID"), classOf[String]);
pollID
}
def convertRemovePollMessage(msg: String):String = {
val gson = new Gson();
val parser = new JsonParser();
val obj = parser.parse(msg).getAsJsonObject();
val pollID = gson.fromJson(obj.get("pollID"), classOf[String]);
pollID
}
}

View File

@ -0,0 +1,159 @@
package org.bigbluebutton.core.apps.poll
import scala.collection.mutable.ArrayBuffer
import scala.collection.mutable.HashMap
class PollModel {
private val polls = new HashMap[String, Poll]()
def numPolls():Int = {
polls.size
}
def createPoll(pollVO: PollVO) {
val questions = new ArrayBuffer[Question]
pollVO.questions.foreach(qv => {
val responses = new ArrayBuffer[Response]
qv.responses.foreach(rv => {
val response = new Response(rv.id, rv.text)
responses += response
})
questions += new Question(qv.id, qv.multiResponse, qv.question, responses.toArray)
})
val poll = new Poll(pollVO.id, pollVO.title, questions.toArray)
polls += poll.id -> poll
}
def updatePoll(pollVO: PollVO):Boolean = {
var success = false
polls.get(pollVO.id) match {
case Some(p) => {
val questions = new ArrayBuffer[Question]
pollVO.questions.foreach(qv => {
val responses = new ArrayBuffer[Response]
qv.responses.foreach(rv => {
val response = new Response(rv.id, rv.text)
responses += response
})
questions += new Question(qv.id, qv.multiResponse, qv.question, responses.toArray)
})
val poll = new Poll(pollVO.id, pollVO.title, questions.toArray)
polls += poll.id -> poll
success = true
}
case None => success = false
}
success
}
def getPolls():Array[PollVO] = {
val poll = new ArrayBuffer[PollVO]
polls.values.foreach(p => {
poll += p.toPollVO
})
poll.toArray
}
def clearPoll(pollID: String):Boolean = {
var success = false
polls.get(pollID) match {
case Some(p) => {
p.clear
success = true
}
case None => success = false
}
success
}
def startPoll(pollID: String):Boolean = {
var success = false
polls.get(pollID) match {
case Some(p) => {
p.start
success = true
}
case None => success = false
}
success
}
def removePoll(pollID: String):Boolean = {
var success = false
polls.get(pollID) match {
case Some(p) => {
polls -= p.id
success = true
}
case None => success = false
}
success
}
def stopPoll(pollID: String):Boolean = {
var success = false
polls.get(pollID) match {
case Some(p) => {
p.stop
success = true
}
case None => success = false
}
success
}
def hasPoll(pollID: String):Boolean = {
var present = false
polls.get(pollID) match {
case Some(p) => {
present = true
}
case None => present = false
}
present
}
def getPoll(pollID: String):Option[PollVO] = {
var poll:Option[PollVO] = None
polls.get(pollID) match {
case Some(p) => {
val questions = new ArrayBuffer[QuestionVO]
p.questions.foreach(q => {
val responses = new ArrayBuffer[ResponseVO]
q.responses.foreach(response => {
val r = new ResponseVO(response.id, response.response, response.getResponders)
responses += r
})
val quest = new QuestionVO(q.id, q.multiResponse, q.question, responses.toArray)
questions += quest
})
poll = Some(new PollVO(p.id, p.title, questions.toArray))
}
case None => poll = None
}
poll
}
def respondToQuestion(pollID: String, questionID: String, responseID: String, responder: Responder) {
polls.get(pollID) match {
case Some(p) => {
p.respondToQuestion(questionID, responseID, responder)
}
case None =>
}
}
}

View File

@ -1,22 +0,0 @@
package org.bigbluebutton.core.apps.poll
class Question(val id: String, val multiResponse: Boolean, val question: String, val responses: Array[Response]) {
def clear() {
responses.foreach(r => r.clear)
}
def hasResponders():Boolean = {
responses.foreach(r => {
if (r.numResponders > 0) return true
})
return false
}
def respondToQuestion(id: String, resp: Responder) {
}
}

View File

@ -1,27 +0,0 @@
package org.bigbluebutton.core.apps.poll
import scala.collection.mutable.ArrayBuffer
case class Responder(val userID: String, val name: String)
class Response(val id: String, val response: String) {
val responders = new ArrayBuffer[Responder]()
def clear() {
responders.clear
}
def addResponder(responder: Responder) {
responders += responder
}
def numResponders():Int = {
responders.length;
}
def getResponders():Array[Responder] = {
var r = new Array[Responder](responders.length)
responders.copyToArray(r)
return r
}
}

View File

@ -1,29 +1,30 @@
package org.bigbluebutton.core.apps.poll.messages
import org.bigbluebutton.core.apps.poll.QuestionType._
import org.bigbluebutton.core.apps.poll._
import org.bigbluebutton.core.api.InMessage
import org.bigbluebutton.core.api.IOutMessage
import org.bigbluebutton.core.apps.poll.Responder
// Poll Messages
case class CreatePoll(meetingID: String, poll: PollVO, requesterID: String) extends InMessage
case class UpdatePoll(meetingID: String, poll: PollVO) extends InMessage
case class CreatePoll(meetingID: String, requesterID: String, poll: PollVO) extends InMessage
case class UpdatePoll(meetingID: String, requesterID: String, poll: PollVO) extends InMessage
case class GetPolls(meetingID: String, requesterID: String) extends InMessage
case class DestroyPoll(meetingID: String, pollID: String) extends InMessage
case class RemovePoll(meetingID: String, pollID: String) extends InMessage
case class SharePoll(meetingID: String, pollID: String) extends InMessage
case class StopPoll(meetingID:String, pollID: String) extends InMessage
case class StartPoll(meetingID:String, pollID: String) extends InMessage
case class ClearPoll(meetingID: String, pollID: String, requesterID: String, force: Boolean=false) extends InMessage
case class GetPollResult(meetingID:String, pollID: String, requesterID: String) extends InMessage
case class DestroyPoll(meetingID: String, requesterID: String, pollID: String) extends InMessage
case class RemovePoll(meetingID: String, requesterID: String, pollID: String) extends InMessage
case class SharePoll(meetingID: String, requesterID: String, pollID: String) extends InMessage
case class StopPoll(meetingID:String, requesterID: String, pollID: String) extends InMessage
case class StartPoll(meetingID:String, requesterID: String, pollID: String) extends InMessage
case class ClearPoll(meetingID: String, requesterID: String, pollID: String, force: Boolean=false) extends InMessage
case class GetPollResult(meetingID:String, requesterID: String, pollID: String) extends InMessage
case class RespondToPoll(meetingID: String, requesterID: String, pollID: String, responses : Array[PollResponseVO])
case class ResponseVO(id: String, text: String)
case class QuestionVO(id: String, multiResponse: Boolean, question: String, responses: Array[ResponseVO])
case class PollVO(id: String, title: String, questions: Array[QuestionVO])
case class PollResponseVO(questionID: String, responses: Array[ResponderVO])
case class ResponderVO(responseID: String, user: Responder)
case class R(id: String, response: String)
case class Q(id: String, questionType: String, question: String, responses: Array[R])
case class P(id: String, title: String, questions: Array[Q], preCreated: Boolean=false)
case class P(id: String, title: String, questions: Array[Q])
// Out Messages
case class GetPollResultReply(meetingID: String, recorded: Boolean, requesterID: String, pollVO: PollVO) extends IOutMessage

View File

@ -38,26 +38,26 @@ class PollClientMessageSender(service: ConnectionInvokerService) extends OutMess
}
private def handlePollClearedOutMsg(msg: PollClearedOutMsg) {
println("PollClientMessageSender - Handling PollClearedOutMsg")
}
private def handlePollStartedOutMsg(msg: PollStartedOutMsg) {
println("PollClientMessageSender - Handling PollStartedOutMsg")
}
private def handlePollStoppedOutMsg(msg: PollStoppedOutMsg) {
println("PollClientMessageSender - Handling PollStoppedOutMsg")
}
private def handlePollRemovedOutMsg(msg: PollRemovedOutMsg) {
println("PollClientMessageSender - Handling PollRemovedOutMsg")
}
private def handlePollUpdatedOutMsg(msg: PollUpdatedOutMsg) {
println("PollClientMessageSender - Handling PollUpdatedOutMsg")
}
private def handlePollCreatedOutMsg(msg: PollCreatedOutMsg) {
println("PollClientMessageSender - Handling PollCreatedOutMsg")
}
}

View File

@ -24,7 +24,7 @@ class UsersClientMessageSender(service: ConnectionInvokerService) extends OutMes
case userLeft: UserLeft => handleUserLeft(userLeft)
case statusChange: UserStatusChange => handleUserStatusChange(statusChange)
case getUsersReply: GetUsersReply => handleGetUsersReply(getUsersReply)
case _ => println("Unhandled message in UsersClientMessageSender")
case _ => // println("Unhandled message in UsersClientMessageSender")
}
}

View File

@ -16,7 +16,7 @@ class UsersEventRedisPublisher(service: MessageSender) extends OutMessageListene
case userJoin: UserJoined => handleUserJoined(userJoin)
case userLeft: UserLeft => handleUserLeft(userLeft)
case statusChange: UserStatusChange => handleUserStatusChange(statusChange)
case _ => println("Unhandled message in UsersClientMessageSender")
case _ => //println("Unhandled message in UsersClientMessageSender")
}
}

View File

@ -20,7 +20,7 @@ class UsersEventRedisRecorder(recorder: RecorderApplication) extends OutMessageL
case userJoin: UserJoined => handleUserJoined(userJoin)
case userLeft: UserLeft => handleUserLeft(userLeft)
case statusChange: UserStatusChange => handleUserStatusChange(statusChange)
case _ => println("Unhandled message in UsersClientMessageSender")
case _ => //println("Unhandled message in UsersClientMessageSender")
}
}

View File

@ -16,7 +16,7 @@ class MeetingEventRedisPublisher(service: MessageSender) extends OutMessageListe
def handleMessage(msg: IOutMessage) {
msg match {
case keepAliveMessageReply: KeepAliveMessageReply => handleKeepAliveMessageReply(keepAliveMessageReply)
case _ => println("Unhandled message in MeetingEventRedisPublisher")
case _ => //println("Unhandled message in MeetingEventRedisPublisher")
}
}

View File

@ -44,6 +44,7 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
</bean>
<bean id="poll.service" class="org.bigbluebutton.conference.service.poll.PollService">
<property name="bigBlueButtonInGW"> <ref bean="bbbInGW"/></property>
</bean>
<bean id="pollRoomsManager"

View File

@ -92,7 +92,8 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
<ref bean="usersRed5ClientSender" />
<ref bean="presentationRedisRecorder" />
<ref bean="usersRedisRecorder" />
<ref bean="meetingEventRedisPublisher" />
<ref bean="meetingEventRedisPublisher" />
<ref bean="pollRed5ClientSender" />
</set>
</property>
</bean>
@ -112,7 +113,11 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
<bean id="presentationRed5ClientSender" class="org.bigbluebutton.core.apps.presentation.red5.PresentationClientMessageSender">
<constructor-arg index="0" ref="connInvokerService"/>
</bean>
<bean id="pollRed5ClientSender" class="org.bigbluebutton.core.apps.poll.red5.PollClientMessageSender">
<constructor-arg index="0" ref="connInvokerService"/>
</bean>
<bean id="meetingMessageHandler" class="org.bigbluebutton.conference.meeting.messaging.redis.MeetingMessageHandler">
<property name="bigBlueButtonInGW"> <ref bean="bbbInGW"/></property>
</bean>

View File

@ -2,11 +2,8 @@ package org.bigbluebutton.core.apps.poll
import org.testng.annotations.BeforeClass
import org.testng.annotations.Test
import org.bigbluebutton.core.apps.poll.messages.PollVO
import com.google.gson.Gson
import com.google.gson.JsonParser
import org.bigbluebutton.core.apps.poll.messages.QuestionVO
import org.bigbluebutton.core.apps.poll.messages.ResponseVO
import org.bigbluebutton.core.apps.poll.messages.R
import org.bigbluebutton.core.util.RandomStringGenerator._
import scala.collection.mutable.ArrayBuffer

View File

@ -0,0 +1,120 @@
package org.bigbluebutton.core.apps.poll
import org.testng.annotations.BeforeClass
import org.testng.annotations.Test
import org.testng.annotations.BeforeMethod
class PollModelTests {
val r1 = new ResponseVO("0", "Answer 1")
val r2 = new ResponseVO("1", "Answer 2")
val r3 = new ResponseVO("2", "Answer 3")
val r4 = new ResponseVO("3", "Answer 4")
var q = new QuestionVO("q1", true, "What is my name?", Array(r1, r2, r3))
val pvo = new PollVO("pollID", "sample poll", Array(q))
@BeforeMethod
def setUp() {
}
@Test(groups = Array[String]( "unit" ))
def createPollTest(){
val model = new PollModel
model.createPoll(pvo)
assert(model.numPolls == 1, "Number of polls should be 1")
assert(model.hasPoll("pollID"), "No poll with id=pollID")
}
@Test(groups = Array[String]( "unit" ))
def updatePollTest(){
val model = new PollModel
model.createPoll(pvo)
assert(model.numPolls == 1, "Number of polls should be 1")
assert(model.hasPoll("pollID"), "No poll with id=pollID")
var q = new QuestionVO("q1", true, "What is my name?", Array(r1, r2, r3, r4))
val newpvo = new PollVO("pollID", "modified sample poll", Array(q))
model.updatePoll(newpvo)
assert(model.numPolls == 1, "Number of polls should be 1")
assert(model.hasPoll("pollID"), "No poll with id=pollID")
model.getPoll("pollID") match {
case Some(spvo) => {
assert(spvo.questions(0).responses.length == 4, "Number of questions doesn't match.")
}
case None =>
}
}
@Test(groups = Array[String]( "unit" ))
def getPollsTest(){
val model = new PollModel
model.createPoll(pvo)
assert(model.numPolls == 1, "Number of polls should be 1")
assert(model.hasPoll("pollID"), "No poll with id=pollID")
var q = new QuestionVO("q1", true, "What is my name?", Array(r1, r2, r3, r4))
val newpvo = new PollVO("pollID-2", "modified sample poll", Array(q))
model.createPoll(newpvo)
assert(model.numPolls == 2, "Number of polls should be 2")
assert(model.hasPoll("pollID-2"), "No poll with id=pollID")
val polls = model.getPolls
assert(polls.length == 2, "Number of polls should be 2")
}
@Test(groups = Array[String]( "unit" ))
def removePollsTest(){
val model = new PollModel
model.createPoll(pvo)
assert(model.numPolls == 1, "Number of polls should be 1")
assert(model.hasPoll("pollID"), "No poll with id=pollID")
var q = new QuestionVO("q1", true, "What is my name?", Array(r1, r2, r3, r4))
val newpvo = new PollVO("pollID-2", "modified sample poll", Array(q))
model.createPoll(newpvo)
assert(model.numPolls == 2, "Number of polls should be 2")
assert(model.hasPoll("pollID-2"), "No poll with id=pollID")
model.removePoll("pollID-2")
assert(model.numPolls == 1, "Number of polls should be 1")
assert(model.hasPoll("pollID"), "No poll with id=pollID")
assert(model.hasPoll("pollID-2") == false, "pollID-2 shouldn't exist")
}
@Test(groups = Array[String]( "unit" ))
def respondPollsTest(){
val model = new PollModel
model.createPoll(pvo)
assert(model.numPolls == 1, "Number of polls should be 1")
assert(model.hasPoll("pollID"), "No poll with id=pollID")
model.respondToQuestion("pollID", "q1", "1", new Responder("user1", "Juan Tamad"))
model.respondToQuestion("pollID", "q1", "0", new Responder("user2", "Asyong Aksaya"))
model.getPoll("pollID") match {
case Some(spvo) => {
assert(spvo.questions(0).responses(1).responders.length == 1, "Question has responders")
assert(spvo.questions(0).responses(0).responders.length == 1, "Question has responders")
}
case None =>
}
}
}

View File

@ -0,0 +1,24 @@
package org.bigbluebutton.core.apps.poll
import org.testng.annotations.BeforeClass
import org.testng.annotations.Test
class PollTests {
var samplePoll:Poll = null
@BeforeClass
def setUp() {
val r1 = new Response("0", "Answer 1")
val r2 = new Response("1", "Answer 2")
val r3 = new Response("2", "Answer 3")
val q = new Question("1", true, "What is my name?", Array(r1, r2, r3))
samplePoll = new Poll("pollID", "Sample Poll", Array(q))
}
@Test(groups = Array[String]( "unit" ))
def createPollTest(){
}
}

View File

@ -76,7 +76,10 @@ package org.bigbluebutton.modules.polling.service
public function startPoll(pollID:String):void
{
var jsonMsg:String = JSON.stringify(pollID);
var map:Object = new Object();
map.pollID = pollID;
var jsonMsg:String = JSON.stringify(map);
trace(LOG + "startPoll [" + jsonMsg + "]");
@ -94,7 +97,10 @@ package org.bigbluebutton.modules.polling.service
public function stopPoll(pollID:String):void
{
var jsonMsg:String = JSON.stringify(pollID);
var map:Object = new Object();
map.pollID = pollID;
var jsonMsg:String = JSON.stringify(map);
trace(LOG + "stopPoll [" + jsonMsg + "]");
@ -112,7 +118,10 @@ package org.bigbluebutton.modules.polling.service
public function removePoll(pollID:String):void
{
var jsonMsg:String = JSON.stringify(pollID);
var map:Object = new Object();
map.pollID = pollID;
var jsonMsg:String = JSON.stringify(map);
trace(LOG + "removePoll [" + jsonMsg + "]");