- receive and process poll messages
This commit is contained in:
parent
edcb307cc8
commit
ba9c36c425
@ -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);
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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) {
|
||||
|
||||
}
|
||||
}
|
@ -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
|
||||
}
|
||||
|
@ -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))
|
||||
}
|
||||
}
|
@ -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) {
|
||||
|
||||
}
|
||||
}
|
@ -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
|
||||
}
|
||||
}
|
@ -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])
|
||||
|
@ -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")
|
||||
}
|
||||
}
|
@ -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")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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"
|
||||
|
@ -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>
|
||||
|
@ -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 + "]");
|
||||
|
||||
|
@ -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)) {
|
||||
|
Loading…
Reference in New Issue
Block a user