work on displaying poll result annotation in flash client

This commit is contained in:
Anton Georgiev 2017-06-23 17:26:53 -04:00
parent 9dc00519db
commit 9a0a4d5669
3 changed files with 46 additions and 31 deletions

View File

@ -1,8 +1,11 @@
package org.bigbluebutton.core.models
import java.util
import java.util.ArrayList
import com.google.gson.Gson
import org.bigbluebutton.common2.domain._
import org.bigbluebutton.core.apps.WhiteboardKeyUtil
import scala.collection.mutable.ArrayBuffer
import scala.collection.mutable.HashMap
@ -45,22 +48,30 @@ object Polls {
}
}
def handleShowPollResultReqMsg(requesterId: String, pollId: String, lm: LiveMeeting): Option[SimplePollResultOutVO] = {
// def send(poll: SimplePollResultOutVO, shape: scala.collection.immutable.Map[String, Object]): Unit = {
// for {
// page <- lm.presModel.getCurrentPage()
// pageId = if (poll.id.contains("deskshare")) "deskshare" else page.id
// annotation = new AnnotationVO(poll.id, WhiteboardKeyUtil.DRAW_END_STATUS, WhiteboardKeyUtil.POLL_RESULT_TYPE, shape, pageId, requesterId, -1)
// } handleSendWhiteboardAnnotationRequest(new SendWhiteboardAnnotationRequest(props.meetingProp.intId, requesterId, annotation))
// }
def handleShowPollResultReqMsg(requesterId: String, pollId: String, lm: LiveMeeting): Option[(SimplePollResultOutVO, AnnotationProps)] = {
def sendWhiteboardAnnotation(annotation: AnnotationProps): Unit = {
lm.wbModel.updateAnnotation(annotation.wbId, annotation.userId, annotation)
annotation
}
def send(poll: SimplePollResultOutVO, shape: scala.collection.immutable.Map[String, Object]): Option[AnnotationProps] = {
for {
page <- lm.presModel.getCurrentPage()
pageId = if (poll.id.contains("deskshare")) "deskshare" else page.id
annotation = new AnnotationProps(poll.id, WhiteboardKeyUtil.DRAW_END_STATUS, WhiteboardKeyUtil.POLL_RESULT_TYPE, shape, pageId, requesterId, -1)
} yield {
sendWhiteboardAnnotation(annotation)
annotation
}
}
for {
result <- getSimplePollResult(pollId, lm.polls)
shape = pollResultToWhiteboardShape(result)
annot <- send(result, shape)
} yield {
// send(result, shape)
showPollResult(pollId, lm.polls)
result
(result, annot)
}
}
@ -164,18 +175,18 @@ object Polls {
private def pollResultToWhiteboardShape(result: SimplePollResultOutVO): scala.collection.immutable.Map[String, Object] = {
val shape = new scala.collection.mutable.HashMap[String, Object]()
shape += "num_respondents" -> new Integer(result.numRespondents)
shape += "num_responders" -> new Integer(result.numResponders)
shape += "type" -> "poll_result"
shape += "numRespondents" -> new Integer(result.numRespondents)
shape += "numResponders" -> new Integer(result.numResponders)
shape += "type" -> WhiteboardKeyUtil.POLL_RESULT_TYPE
shape += "id" -> result.id
shape += "status" -> "DRAW_END"
shape += "status" -> WhiteboardKeyUtil.DRAW_END_STATUS
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)
amap.put("numVotes", ans.numVotes: java.lang.Integer)
answers += amap
})
@ -184,14 +195,10 @@ object Polls {
// Hardcode poll result display location for now to display result
// in bottom-right corner.
val display = new ArrayList[Double]()
val shapeHeight = 6.66 * answers.size
display.add(66.0)
display.add(100 - shapeHeight)
display.add(34.0)
display.add(shapeHeight)
var mapA = List(66.0, 100 - shapeHeight, 34.0, shapeHeight)
shape += "points" -> display
shape += "points" -> mapA
shape.toMap
}

View File

@ -1,11 +1,11 @@
package org.bigbluebutton.core2.message.handlers
import org.bigbluebutton.common2.messages.MessageBody.PollShowResultEvtMsgBody
import org.bigbluebutton.common2.messages.MessageBody.{ PollShowResultEvtMsgBody, SendWhiteboardAnnotationEvtMsgBody, SendWhiteboardAnnotationPubMsgBody }
import org.bigbluebutton.common2.messages._
import org.bigbluebutton.core.OutMessageGateway
import org.bigbluebutton.core.models.Polls
import org.bigbluebutton.core.running.MeetingActor
import org.bigbluebutton.common2.domain.SimplePollResultOutVO
import org.bigbluebutton.common2.domain.{ AnnotationProps, SimplePollResultOutVO }
trait ShowPollResultReqMsgHdlr {
this: MeetingActor =>
@ -14,7 +14,8 @@ trait ShowPollResultReqMsgHdlr {
def handleShowPollResultReqMsg(msg: ShowPollResultReqMsg): Unit = {
def broadcastEvent(msg: ShowPollResultReqMsg, result: SimplePollResultOutVO): Unit = {
def broadcastEvent(msg: ShowPollResultReqMsg, result: SimplePollResultOutVO, annot: AnnotationProps): Unit = {
// PollShowResultEvtMsg
val routing = Routing.addMsgToClientRouting(MessageTypes.BROADCAST_TO_MEETING, props.meetingProp.intId, msg.header.userId)
val envelope = BbbCoreEnvelope(PollShowResultEvtMsg.NAME, routing)
val header = BbbClientMsgHeader(PollShowResultEvtMsg.NAME, props.meetingProp.intId, msg.header.userId)
@ -23,12 +24,23 @@ trait ShowPollResultReqMsgHdlr {
val event = PollShowResultEvtMsg(header, body)
val msgEvent = BbbCommonEnvCoreMsg(envelope, event)
outGW.send(msgEvent)
// SendWhiteboardAnnotationPubMsg
val annotationRouting = Routing.addMsgToClientRouting(MessageTypes.BROADCAST_TO_MEETING, props.meetingProp.intId, msg.header.userId)
val annotationEnvelope = BbbCoreEnvelope(SendWhiteboardAnnotationEvtMsg.NAME, annotationRouting)
val annotationHeader = BbbClientMsgHeader(SendWhiteboardAnnotationEvtMsg.NAME, props.meetingProp.intId, msg.header.userId)
val annotMsgBody = SendWhiteboardAnnotationEvtMsgBody(annot)
val annotationEvent = SendWhiteboardAnnotationEvtMsg(annotationHeader, annotMsgBody)
val annotationMsgEvent = BbbCommonEnvCoreMsg(annotationEnvelope, annotationEvent)
outGW.send(annotationMsgEvent)
}
for {
result <- Polls.handleShowPollResultReqMsg(msg.header.userId, msg.body.pollId, liveMeeting)
(result, annotationProp) <- Polls.handleShowPollResultReqMsg(msg.header.userId, msg.body.pollId, liveMeeting)
} yield {
broadcastEvent(msg, result)
broadcastEvent(msg, result, annotationProp)
}
}
}

View File

@ -83,11 +83,7 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
<EventHandlers type="{WhiteboardCursorEvent.SEND_CURSOR_POSITION}" >
<MethodInvoker generator="{WhiteboardService}" method="sendCursorPosition" arguments="{event}" />
</EventHandlers>
<EventHandlers type="{GetWhiteboardShapesCommand.GET_SHAPES}" >
<MethodInvoker generator="{WhiteboardService}" method="getAnnotationHistory" arguments="{event}" />
</EventHandlers>
<EventHandlers type="{BBBEvent.RECONNECT_BIGBLUEBUTTON_SUCCEEDED_EVENT}" >
<MethodInvoker generator="{WhiteboardManager}" method="removeAnnotationsHistory" />
</EventHandlers>