From 72659e62acd72bdf83b8fbb6cbb4b8664518dc87 Mon Sep 17 00:00:00 2001 From: Richard Alam Date: Thu, 2 Jul 2015 22:16:11 +0000 Subject: [PATCH] - try displaying poll result as whiteboard shape --- .../service/whiteboard/WhiteboardKeyUtil.java | 1 + .../core/BigBlueButtonInGW.scala | 4 +-- .../org/bigbluebutton/core/apps/Poll.scala | 3 -- .../org/bigbluebutton/core/apps/PollApp.scala | 32 ++++++++++++++++++- .../core/apps/WhiteboardModel.scala | 2 +- .../senders/UsersMessageToJsonConverter.scala | 2 +- .../WhiteboardEventRedisRecorder.scala | 11 +++++-- .../bigbluebutton/common/messages/Util.java | 2 ++ .../client/WhiteboardClientMessageSender.java | 7 +--- 9 files changed, 48 insertions(+), 16 deletions(-) diff --git a/akka-bbb-apps/src/main/java/org/bigbluebutton/core/service/whiteboard/WhiteboardKeyUtil.java b/akka-bbb-apps/src/main/java/org/bigbluebutton/core/service/whiteboard/WhiteboardKeyUtil.java index 59189937d1..7a0e30e175 100755 --- a/akka-bbb-apps/src/main/java/org/bigbluebutton/core/service/whiteboard/WhiteboardKeyUtil.java +++ b/akka-bbb-apps/src/main/java/org/bigbluebutton/core/service/whiteboard/WhiteboardKeyUtil.java @@ -8,6 +8,7 @@ public class WhiteboardKeyUtil { public static final String ELLIPSE_TYPE = "ellipse"; public static final String TRIANGLE_TYPE = "triangle"; public static final String LINE_TYPE = "line"; + public static final String POLL_RESULT_TYPE = "poll_result"; public static final String TEXT_CREATED_STATUS = "textCreated"; public static final String DRAW_START_STATUS = "DRAW_START"; diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/BigBlueButtonInGW.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/BigBlueButtonInGW.scala index e264573aeb..149a8136e2 100755 --- a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/BigBlueButtonInGW.scala +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/BigBlueButtonInGW.scala @@ -328,7 +328,7 @@ class BigBlueButtonInGW(val system: ActorSystem, outGW: MessageOutGateway, voice * Message Interface for Whiteboard * ***************************************************************** */ - private def buildAnnotation(annotation: Map[String, Object]): Option[AnnotationVO] = { + private def buildAnnotation(annotation: scala.collection.mutable.Map[String, Object]): Option[AnnotationVO] = { var shape: Option[AnnotationVO] = None val id = annotation.getOrElse("id", null).asInstanceOf[String] @@ -345,7 +345,7 @@ class BigBlueButtonInGW(val system: ActorSystem, outGW: MessageOutGateway, voice } def sendWhiteboardAnnotation(meetingID: String, requesterID: String, annotation: java.util.Map[String, Object]) { - val ann = mapAsScalaMap(annotation).toMap + val ann: scala.collection.mutable.Map[String, Object] = mapAsScalaMap(annotation) buildAnnotation(ann) match { case Some(shape) => { diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/Poll.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/Poll.scala index f1f22e7c21..5aec47d5a7 100755 --- a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/Poll.scala +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/Poll.scala @@ -231,9 +231,7 @@ class Answer(val id: Int, val key: String, val text: Option[String]) { responders.clear } def addResponder(responder: Responder) { - println("********************************************************************** Add response for key=[" + key + "] votes=[" + numResponders + "]") responders += responder - println("********************************************************************** Added response for key=[" + key + "] votes=[" + numResponders + "]") } def numResponders(): Int = { @@ -251,7 +249,6 @@ class Answer(val id: Int, val key: String, val text: Option[String]) { } def toSimpleVoteOutVO(): SimpleVoteOutVO = { - println("********************************************************************** Num response for key=[" + key + "] votes=[" + numResponders + "]") new SimpleVoteOutVO(id, key, numResponders) } } \ No newline at end of file diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/PollApp.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/PollApp.scala index f132a45489..8f12fe068a 100755 --- a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/PollApp.scala +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/PollApp.scala @@ -4,6 +4,8 @@ import org.bigbluebutton.core.api._ import org.bigbluebutton.core.MeetingActor import scala.collection.mutable.HashMap import scala.collection.mutable.ArrayBuffer +import org.bigbluebutton.core.service.whiteboard.WhiteboardKeyUtil +import com.google.gson.Gson trait PollApp { this: MeetingActor => @@ -60,11 +62,39 @@ trait PollApp { } } + def pollResultToWhiteboardShape(result: SimplePollResultOutVO, msg: ShowPollResultRequest): scala.collection.immutable.Map[String, Object] = { + val shape = new scala.collection.mutable.HashMap[String, Object]() + + val answers = new ArrayBuffer[java.util.HashMap[String, Object]]; + result.answers.foreach(ans => { + val amap = new java.util.HashMap[String, Object]() + amap.put("id", ans.id: java.lang.Integer) + amap.put("key", ans.key) + amap.put("num_votes", ans.numVotes: java.lang.Integer) + answers += amap + }) + + val gson = new Gson() + shape += "result" -> gson.toJson(answers.toArray) + + val display = Array(0, 0, 200, 200) + shape += "points" -> display + shape.toMap + } + def handleShowPollResultRequest(msg: ShowPollResultRequest) { pollModel.getSimplePollResult(msg.pollId) match { case Some(poll) => { pollModel.showPollResult(poll.id) - outGW.send(new PollShowResultMessage(mProps.meetingID, mProps.recorded, msg.requesterId, msg.pollId, poll)) + val shape = pollResultToWhiteboardShape(poll, msg) + + for { + page <- presModel.getCurrentPage() + annotation = new AnnotationVO(poll.id, WhiteboardKeyUtil.DRAW_END_STATUS, WhiteboardKeyUtil.POLL_RESULT_TYPE, shape, page.id) + } this.context.self ! new SendWhiteboardAnnotationRequest(mProps.meetingID, msg.requesterId, annotation) + + // outGW.send(new PollShowResultMessage(mProps.meetingID, mProps.recorded, msg.requesterId, msg.pollId, poll)) + } case None => { val result = new RequestResult(StatusCodes.NOT_FOUND, Some(Array(ErrorCodes.RESOURCE_NOT_FOUND))) diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/WhiteboardModel.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/WhiteboardModel.scala index 521b063f50..420797598c 100755 --- a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/WhiteboardModel.scala +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/WhiteboardModel.scala @@ -2,7 +2,7 @@ package org.bigbluebutton.core.apps import scala.collection.mutable.ArrayBuffer -case class AnnotationVO(id: String, status: String, shapeType: String, shape: scala.collection.immutable.Map[String, Object], wbId: String) +case class AnnotationVO(id: String, status: String, shapeType: String, shape: scala.collection.immutable.Map[String, Any], wbId: String) class WhiteboardModel { private var _whiteboards = new scala.collection.immutable.HashMap[String, Whiteboard]() diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/pubsub/senders/UsersMessageToJsonConverter.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/pubsub/senders/UsersMessageToJsonConverter.scala index f03dc407ec..c67f0fc3d4 100755 --- a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/pubsub/senders/UsersMessageToJsonConverter.scala +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/pubsub/senders/UsersMessageToJsonConverter.scala @@ -20,7 +20,7 @@ object UsersMessageToJsonConverter { wuser += "presenter" -> user.presenter wuser += "has_stream" -> user.hasStream wuser += "locked" -> user.locked - wuser += "webcam_stream" -> user.webcamStreams + wuser += "webcam_stream" -> user.webcamStreams.toArray wuser += "phone_user" -> user.phoneUser wuser += "listenOnly" -> user.listenOnly diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/recorders/WhiteboardEventRedisRecorder.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/recorders/WhiteboardEventRedisRecorder.scala index 5613d0d9ab..a252439b24 100755 --- a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/recorders/WhiteboardEventRedisRecorder.scala +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/recorders/WhiteboardEventRedisRecorder.scala @@ -53,7 +53,13 @@ class WhiteboardEventRedisRecorder(recorder: RecorderApplication) extends OutMes event.setPresentation(getPresentationId(msg.whiteboardId)) event.setPageNumber(getPageNum(msg.whiteboardId)) event.setWhiteboardId(msg.whiteboardId) - event.addAnnotation(mapAsJavaMap(msg.shape.shape)) + + // FIXME: Need to fix recording of wb event (ralam june 29, 2015) + //val ann: java.util.Map[String, Any] = mapAsJavaMap(msg.shape.shape) + // val ann: java.util.Map[String, Object] = mapAsJavaMap(msg.shape.shape) + // val ann2: java.util.Map[String, Object] = mapAsJavaMap(ann) + + // event.addAnnotation(mapAsJavaMap(ann)) recorder.record(msg.meetingID, event) } else { val event = new AddShapeWhiteboardRecordEvent() @@ -62,7 +68,8 @@ class WhiteboardEventRedisRecorder(recorder: RecorderApplication) extends OutMes event.setPresentation(getPresentationId(msg.whiteboardId)) event.setPageNumber(getPageNum(msg.whiteboardId)) event.setWhiteboardId(msg.whiteboardId); - event.addAnnotation(mapAsJavaMap(msg.shape.shape)) + // FIXME: Need to fix recording of wb event (ralam june 29, 2015) + // event.addAnnotation(mapAsJavaMap(msg.shape.shape)) recorder.record(msg.meetingID, event) } } diff --git a/bbb-common-message/src/main/java/org/bigbluebutton/common/messages/Util.java b/bbb-common-message/src/main/java/org/bigbluebutton/common/messages/Util.java index 6d36bbe261..679887a2d4 100755 --- a/bbb-common-message/src/main/java/org/bigbluebutton/common/messages/Util.java +++ b/bbb-common-message/src/main/java/org/bigbluebutton/common/messages/Util.java @@ -200,6 +200,8 @@ public class Util { } + + public Map extractAnnotation(JsonObject annotationElement) { //NON-TEXT SHAPE if (annotationElement.has(Constants.ID) diff --git a/bigbluebutton-apps/src/main/java/org/bigbluebutton/red5/client/WhiteboardClientMessageSender.java b/bigbluebutton-apps/src/main/java/org/bigbluebutton/red5/client/WhiteboardClientMessageSender.java index 7e22b512ed..7f8b4f4f5f 100755 --- a/bigbluebutton-apps/src/main/java/org/bigbluebutton/red5/client/WhiteboardClientMessageSender.java +++ b/bigbluebutton-apps/src/main/java/org/bigbluebutton/red5/client/WhiteboardClientMessageSender.java @@ -70,15 +70,13 @@ public class WhiteboardClientMessageSender { } } - private void processSendWhiteboardAnnotationReplyMessage( - SendWhiteboardAnnotationReplyMessage msg) { + private void processSendWhiteboardAnnotationReplyMessage(SendWhiteboardAnnotationReplyMessage msg) { Map args = new HashMap(); args.put("whiteboardId", msg.whiteboardId); Map shape = new HashMap(); - System.out.println("\n\n"+msg.shape.toString() +"\n\n"); shape.put("id", msg.shape.get("id")); shape.put("type", msg.shape.get("type")); shape.put("status", msg.shape.get("status")); @@ -90,9 +88,6 @@ public class WhiteboardClientMessageSender { Gson gson = new Gson(); message.put("msg", gson.toJson(args)); - System.out.println("RedisPubSubMessageHandler - processSendWhiteboardAnnotationReplyMessage \n" - + message.get("msg").toString() + "\n"); - //broadcast message BroadcastClientMessage b = new BroadcastClientMessage(msg.meetingId, "WhiteboardNewAnnotationCommand", message); service.sendMessage(b);