From ce55210ac5aa4bda386f22ed76ca59307ca636a4 Mon Sep 17 00:00:00 2001 From: Richard Alam Date: Mon, 24 Jun 2013 16:32:11 +0000 Subject: [PATCH 1/3] write some tests for the PollModel --- .../bigbluebutton/core/apps/poll/Poll.scala | 26 ++- .../core/apps/poll/PollApp.scala | 112 ++---------- .../core/apps/poll/PollModel.scala | 169 ++++++++++++++++++ .../apps/poll/messages/PollMessages.scala | 5 + .../core/apps/poll/PollModelTests.scala | 115 ++++++++++++ .../core/apps/poll/PollTests.scala | 24 +++ 6 files changed, 349 insertions(+), 102 deletions(-) create mode 100755 bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/poll/PollModel.scala create mode 100755 bigbluebutton-apps/src/test/scala/org/bigbluebutton/core/apps/poll/PollModelTests.scala create mode 100755 bigbluebutton-apps/src/test/scala/org/bigbluebutton/core/apps/poll/PollTests.scala diff --git a/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/poll/Poll.scala b/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/poll/Poll.scala index f67a646fb5..fd66d7c18f 100755 --- a/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/poll/Poll.scala +++ b/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/poll/Poll.scala @@ -4,20 +4,32 @@ import scala.collection.mutable.HashMap import QuestionType._ 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 = { diff --git a/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/poll/PollApp.scala b/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/poll/PollApp.scala index 8bcd4464d1..4670f58cfb 100755 --- a/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/poll/PollApp.scala +++ b/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/poll/PollApp.scala @@ -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 { @@ -25,55 +25,24 @@ class PollApp(meetingID: String, recorded: Boolean, outGW: MessageOutGateway) { } 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)) } 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)) - } - } + + + outGW.send(new PollStartedOutMsg(meetingID, recorded, msg.pollID)) } 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)) - } - } + + + outGW.send(new PollStoppedOutMsg(meetingID, recorded, msg.pollID)) } private def handleSharePoll(msg: SharePoll) { @@ -81,13 +50,9 @@ class PollApp(meetingID: String, recorded: Boolean, outGW: MessageOutGateway) { } 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)) - } - } + + + outGW.send(new PollRemovedOutMsg(meetingID, recorded, msg.pollID)) } private def handleDestroyPoll(msg: DestroyPoll) { @@ -95,55 +60,12 @@ 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)) + } } 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)) + outGW.send(new PollCreatedOutMsg(meetingID, recorded, msg.poll.id, msg.poll)) } } \ No newline at end of file diff --git a/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/poll/PollModel.scala b/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/poll/PollModel.scala new file mode 100755 index 0000000000..65fcac5e65 --- /dev/null +++ b/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/poll/PollModel.scala @@ -0,0 +1,169 @@ +package org.bigbluebutton.core.apps.poll + +import org.bigbluebutton.core.apps.poll.messages.PollVO +import scala.collection.mutable.ArrayBuffer +import scala.collection.mutable.HashMap +import org.bigbluebutton.core.apps.poll.messages.QuestionVO +import org.bigbluebutton.core.apps.poll.messages.ResponseVO + +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 => { + 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) + }) + + 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) + 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) { + + } +} \ No newline at end of file diff --git a/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/poll/messages/PollMessages.scala b/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/poll/messages/PollMessages.scala index 7398691c3b..24a335b1dd 100755 --- a/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/poll/messages/PollMessages.scala +++ b/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/poll/messages/PollMessages.scala @@ -4,6 +4,7 @@ package org.bigbluebutton.core.apps.poll.messages import org.bigbluebutton.core.apps.poll.QuestionType._ 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 @@ -16,6 +17,10 @@ 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 RespondToPoll(meetingID: String, pollID: String, responses : Array[PollResponseVO]) + +case class PollResponseVO(questionID: String, responses: Array[ResponderVO]) +case class ResponderVO(responseID: String, user: Responder) case class ResponseVO(id: String, text: String) case class QuestionVO(id: String, multiResponse: Boolean, question: String, responses: Array[ResponseVO]) diff --git a/bigbluebutton-apps/src/test/scala/org/bigbluebutton/core/apps/poll/PollModelTests.scala b/bigbluebutton-apps/src/test/scala/org/bigbluebutton/core/apps/poll/PollModelTests.scala new file mode 100755 index 0000000000..ff14406763 --- /dev/null +++ b/bigbluebutton-apps/src/test/scala/org/bigbluebutton/core/apps/poll/PollModelTests.scala @@ -0,0 +1,115 @@ +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 org.bigbluebutton.core.apps.poll.messages.ResponseVO +import org.bigbluebutton.core.apps.poll.messages.QuestionVO +import org.testng.annotations.BeforeMethod +import org.bigbluebutton.core.apps.poll.messages.PollVO + +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")) + +// assert(model.getPoll("pollID").) + } +} \ No newline at end of file diff --git a/bigbluebutton-apps/src/test/scala/org/bigbluebutton/core/apps/poll/PollTests.scala b/bigbluebutton-apps/src/test/scala/org/bigbluebutton/core/apps/poll/PollTests.scala new file mode 100755 index 0000000000..04a0b34576 --- /dev/null +++ b/bigbluebutton-apps/src/test/scala/org/bigbluebutton/core/apps/poll/PollTests.scala @@ -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(){ + + } +} \ No newline at end of file From edcb307cc89bbc2767b04002206834139c62a6ca Mon Sep 17 00:00:00 2001 From: Richard Alam Date: Mon, 24 Jun 2013 18:01:12 +0000 Subject: [PATCH 2/3] - clean up and simply structure --- .../bigbluebutton/core/apps/poll/Poll.scala | 73 ++++++++++++++++++- .../core/apps/poll/PollApp.scala | 23 +++--- .../core/apps/poll/PollMessageConverter.scala | 3 - .../core/apps/poll/PollModel.scala | 28 +++---- .../core/apps/poll/Question.scala | 22 ------ .../core/apps/poll/Response.scala | 27 ------- .../apps/poll/messages/PollMessages.scala | 8 +- .../apps/poll/PollMessageConverterTest.scala | 3 - .../core/apps/poll/PollModelTests.scala | 15 ++-- 9 files changed, 105 insertions(+), 97 deletions(-) delete mode 100755 bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/poll/Question.scala delete mode 100755 bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/poll/Response.scala diff --git a/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/poll/Poll.scala b/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/poll/Poll.scala index fd66d7c18f..bdbaabddd2 100755 --- a/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/poll/Poll.scala +++ b/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/poll/Poll.scala @@ -1,7 +1,12 @@ 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 started: Boolean = false @@ -40,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 + } } \ No newline at end of file diff --git a/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/poll/PollApp.scala b/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/poll/PollApp.scala index 4670f58cfb..5f8fcf9c2b 100755 --- a/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/poll/PollApp.scala +++ b/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/poll/PollApp.scala @@ -34,25 +34,28 @@ class PollApp(meetingID: String, recorded: Boolean, outGW: MessageOutGateway) { } private def handleStartPoll(msg: StartPoll) { - - - 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)) + } } private def handleStopPoll(msg: StopPoll) { - - - 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)) + } } private def handleSharePoll(msg: SharePoll) { - + } private def handleRemovePoll(msg: RemovePoll) { - - - 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)) + } } private def handleDestroyPoll(msg: DestroyPoll) { diff --git a/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/poll/PollMessageConverter.scala b/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/poll/PollMessageConverter.scala index 671757f50c..c51732c5dd 100755 --- a/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/poll/PollMessageConverter.scala +++ b/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/poll/PollMessageConverter.scala @@ -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 diff --git a/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/poll/PollModel.scala b/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/poll/PollModel.scala index 65fcac5e65..a9fbc41573 100755 --- a/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/poll/PollModel.scala +++ b/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/poll/PollModel.scala @@ -1,10 +1,7 @@ package org.bigbluebutton.core.apps.poll -import org.bigbluebutton.core.apps.poll.messages.PollVO import scala.collection.mutable.ArrayBuffer import scala.collection.mutable.HashMap -import org.bigbluebutton.core.apps.poll.messages.QuestionVO -import org.bigbluebutton.core.apps.poll.messages.ResponseVO class PollModel { @@ -56,20 +53,8 @@ class PollModel { def getPolls():Array[PollVO] = { 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) + polls.values.foreach(p => { + poll += p.toPollVO }) poll.toArray @@ -148,7 +133,7 @@ class PollModel { p.questions.foreach(q => { val responses = new ArrayBuffer[ResponseVO] q.responses.foreach(response => { - val r = new ResponseVO(response.id, response.response) + val r = new ResponseVO(response.id, response.response, response.getResponders) responses += r }) @@ -164,6 +149,11 @@ class PollModel { } def respondToQuestion(pollID: String, questionID: String, responseID: String, responder: Responder) { - + polls.get(pollID) match { + case Some(p) => { + p.respondToQuestion(questionID, responseID, responder) + } + case None => + } } } \ No newline at end of file diff --git a/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/poll/Question.scala b/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/poll/Question.scala deleted file mode 100755 index 4fa5b12cea..0000000000 --- a/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/poll/Question.scala +++ /dev/null @@ -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) { - - } - -} \ No newline at end of file diff --git a/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/poll/Response.scala b/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/poll/Response.scala deleted file mode 100755 index fc2352e1ba..0000000000 --- a/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/poll/Response.scala +++ /dev/null @@ -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 - } -} \ No newline at end of file diff --git a/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/poll/messages/PollMessages.scala b/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/poll/messages/PollMessages.scala index 24a335b1dd..f45d12d724 100755 --- a/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/poll/messages/PollMessages.scala +++ b/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/poll/messages/PollMessages.scala @@ -1,7 +1,7 @@ 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 @@ -22,13 +22,11 @@ case class RespondToPoll(meetingID: String, pollID: String, responses : Array[Po case class PollResponseVO(questionID: String, responses: Array[ResponderVO]) case class ResponderVO(responseID: String, user: Responder) -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 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 diff --git a/bigbluebutton-apps/src/test/scala/org/bigbluebutton/core/apps/poll/PollMessageConverterTest.scala b/bigbluebutton-apps/src/test/scala/org/bigbluebutton/core/apps/poll/PollMessageConverterTest.scala index 3f1e3daa06..a866d504a5 100755 --- a/bigbluebutton-apps/src/test/scala/org/bigbluebutton/core/apps/poll/PollMessageConverterTest.scala +++ b/bigbluebutton-apps/src/test/scala/org/bigbluebutton/core/apps/poll/PollMessageConverterTest.scala @@ -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 diff --git a/bigbluebutton-apps/src/test/scala/org/bigbluebutton/core/apps/poll/PollModelTests.scala b/bigbluebutton-apps/src/test/scala/org/bigbluebutton/core/apps/poll/PollModelTests.scala index ff14406763..cd82f4b6a8 100755 --- a/bigbluebutton-apps/src/test/scala/org/bigbluebutton/core/apps/poll/PollModelTests.scala +++ b/bigbluebutton-apps/src/test/scala/org/bigbluebutton/core/apps/poll/PollModelTests.scala @@ -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 org.bigbluebutton.core.apps.poll.messages.ResponseVO -import org.bigbluebutton.core.apps.poll.messages.QuestionVO import org.testng.annotations.BeforeMethod -import org.bigbluebutton.core.apps.poll.messages.PollVO + class PollModelTests { val r1 = new ResponseVO("0", "Answer 1") @@ -109,7 +106,15 @@ class PollModelTests { 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 => + } -// assert(model.getPoll("pollID").) } } \ No newline at end of file From ba9c36c4259dbfabf6763950cf63f6b49c5fd79a Mon Sep 17 00:00:00 2001 From: Richard Alam Date: Mon, 24 Jun 2013 21:13:53 +0000 Subject: [PATCH 3/3] - receive and process poll messages --- .../conference/service/poll/PollInGW.java | 15 ++++++++ .../conference/service/poll/PollService.java | 36 ++++++++++++------ .../core/api/IBigBlueButtonInGW.java | 7 ++++ .../core/BigBlueButtonInGW.scala | 27 ++++++++++++++ .../org/bigbluebutton/core/Meeting.scala | 1 + .../core/apps/poll/PollApp.scala | 20 ++++++++-- .../core/apps/poll/PollInGateway.scala | 37 ++++++++++++++++++- .../core/apps/poll/PollMessageConverter.scala | 32 +++++++++++++++- .../apps/poll/messages/PollMessages.scala | 22 +++++------ .../poll/red5/PollClientMessageSender.scala | 12 +++--- .../users/red5/UsersClientMessageSender.scala | 2 +- .../redis/UsersEventRedisPublisher.scala | 2 +- .../users/redis/UsersEventRedisRecorder.scala | 2 +- .../meeting/MeetingEventRedisPublisher.scala | 2 +- .../src/main/webapp/WEB-INF/bbb-app-poll.xml | 1 + .../src/main/webapp/WEB-INF/red5-web.xml | 9 ++++- .../modules/polling/service/MessageSender.as | 15 ++++++-- .../api/messaging/RedisMessagingService.java | 1 - 18 files changed, 198 insertions(+), 45 deletions(-) create mode 100755 bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/service/poll/PollInGW.java diff --git a/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/service/poll/PollInGW.java b/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/service/poll/PollInGW.java new file mode 100755 index 0000000000..9d30376254 --- /dev/null +++ b/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/service/poll/PollInGW.java @@ -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); +} diff --git a/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/service/poll/PollService.java b/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/service/poll/PollService.java index 673527b978..bc7e4be0ab 100755 --- a/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/service/poll/PollService.java +++ b/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/service/poll/PollService.java @@ -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); } } diff --git a/bigbluebutton-apps/src/main/java/org/bigbluebutton/core/api/IBigBlueButtonInGW.java b/bigbluebutton-apps/src/main/java/org/bigbluebutton/core/api/IBigBlueButtonInGW.java index 6cda77d855..0f928a0499 100755 --- a/bigbluebutton-apps/src/main/java/org/bigbluebutton/core/api/IBigBlueButtonInGW.java +++ b/bigbluebutton-apps/src/main/java/org/bigbluebutton/core/api/IBigBlueButtonInGW.java @@ -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); } diff --git a/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/BigBlueButtonInGW.scala b/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/BigBlueButtonInGW.scala index 452ea9c8e3..26c8c6ed3d 100755 --- a/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/BigBlueButtonInGW.scala +++ b/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/BigBlueButtonInGW.scala @@ -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) { + + } } \ No newline at end of file diff --git a/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/Meeting.scala b/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/Meeting.scala index fd292b8e5e..7a4d3c165c 100755 --- a/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/Meeting.scala +++ b/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/Meeting.scala @@ -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 } diff --git a/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/poll/PollApp.scala b/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/poll/PollApp.scala index 5f8fcf9c2b..f66b908ae9 100755 --- a/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/poll/PollApp.scala +++ b/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/poll/PollApp.scala @@ -21,6 +21,7 @@ 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 } } @@ -30,20 +31,28 @@ class PollApp(meetingID: String, recorded: Boolean, outGW: MessageOutGateway) { } private def handleClearPoll(msg: ClearPoll) { - if (model.clearPoll(msg.pollID)) 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) { 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) { 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" ) } } @@ -55,7 +64,9 @@ class PollApp(meetingID: String, recorded: Boolean, outGW: MessageOutGateway) { 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) { @@ -65,10 +76,13 @@ class PollApp(meetingID: String, recorded: Boolean, outGW: MessageOutGateway) { private def handleUpdatePoll(msg: UpdatePoll) { 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) { + model.createPoll(msg.poll) outGW.send(new PollCreatedOutMsg(meetingID, recorded, msg.poll.id, msg.poll)) } } \ No newline at end of file diff --git a/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/poll/PollInGateway.scala b/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/poll/PollInGateway.scala index 13dd84b021..cf06bf7acb 100755 --- a/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/poll/PollInGateway.scala +++ b/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/poll/PollInGateway.scala @@ -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) { + + } } \ No newline at end of file diff --git a/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/poll/PollMessageConverter.scala b/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/poll/PollMessageConverter.scala index c51732c5dd..7c2ae81fc2 100755 --- a/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/poll/PollMessageConverter.scala +++ b/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/poll/PollMessageConverter.scala @@ -45,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 = { @@ -93,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 + } } \ No newline at end of file diff --git a/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/poll/messages/PollMessages.scala b/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/poll/messages/PollMessages.scala index f45d12d724..059697485c 100755 --- a/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/poll/messages/PollMessages.scala +++ b/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/poll/messages/PollMessages.scala @@ -7,23 +7,21 @@ 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 RespondToPoll(meetingID: String, pollID: String, responses : Array[PollResponseVO]) +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 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]) diff --git a/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/poll/red5/PollClientMessageSender.scala b/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/poll/red5/PollClientMessageSender.scala index d188508d91..80f43f3cc8 100755 --- a/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/poll/red5/PollClientMessageSender.scala +++ b/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/poll/red5/PollClientMessageSender.scala @@ -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") } } \ No newline at end of file diff --git a/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/users/red5/UsersClientMessageSender.scala b/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/users/red5/UsersClientMessageSender.scala index a849ed4fdf..248282c4e0 100755 --- a/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/users/red5/UsersClientMessageSender.scala +++ b/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/users/red5/UsersClientMessageSender.scala @@ -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") } } diff --git a/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/users/redis/UsersEventRedisPublisher.scala b/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/users/redis/UsersEventRedisPublisher.scala index 6225827c7a..ce577464f9 100755 --- a/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/users/redis/UsersEventRedisPublisher.scala +++ b/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/users/redis/UsersEventRedisPublisher.scala @@ -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") } } diff --git a/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/users/redis/UsersEventRedisRecorder.scala b/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/users/redis/UsersEventRedisRecorder.scala index c1e4e27a8c..9886995621 100755 --- a/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/users/redis/UsersEventRedisRecorder.scala +++ b/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/apps/users/redis/UsersEventRedisRecorder.scala @@ -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") } } diff --git a/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/meeting/MeetingEventRedisPublisher.scala b/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/meeting/MeetingEventRedisPublisher.scala index a583968557..ff0660f019 100755 --- a/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/meeting/MeetingEventRedisPublisher.scala +++ b/bigbluebutton-apps/src/main/scala/org/bigbluebutton/core/meeting/MeetingEventRedisPublisher.scala @@ -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") } } diff --git a/bigbluebutton-apps/src/main/webapp/WEB-INF/bbb-app-poll.xml b/bigbluebutton-apps/src/main/webapp/WEB-INF/bbb-app-poll.xml index 34327131ae..49c29ad6bb 100755 --- a/bigbluebutton-apps/src/main/webapp/WEB-INF/bbb-app-poll.xml +++ b/bigbluebutton-apps/src/main/webapp/WEB-INF/bbb-app-poll.xml @@ -44,6 +44,7 @@ with BigBlueButton; if not, see . + . - + + @@ -112,7 +113,11 @@ with BigBlueButton; if not, see . - + + + + + diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/polling/service/MessageSender.as b/bigbluebutton-client/src/org/bigbluebutton/modules/polling/service/MessageSender.as index 2f7ff8354a..e2057ce0b2 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/polling/service/MessageSender.as +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/polling/service/MessageSender.as @@ -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 + "]"); diff --git a/bigbluebutton-web/src/java/org/bigbluebutton/api/messaging/RedisMessagingService.java b/bigbluebutton-web/src/java/org/bigbluebutton/api/messaging/RedisMessagingService.java index 323acf27d6..0822b0b127 100755 --- a/bigbluebutton-web/src/java/org/bigbluebutton/api/messaging/RedisMessagingService.java +++ b/bigbluebutton-web/src/java/org/bigbluebutton/api/messaging/RedisMessagingService.java @@ -218,7 +218,6 @@ public class RedisMessagingService implements MessagingService { if(channel.equalsIgnoreCase(MessagingConstants.SYSTEM_CHANNEL)){ String messageId = map.get("messageId"); - log.debug("*** Meeting {} Message {}", meetingId, messageId); for (MessageListener listener : listeners) { if(MessagingConstants.MEETING_STARTED_EVENT.equalsIgnoreCase(messageId)) {