Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void destroyPolls(String name){
Jedis jedis = dbConnect();
ArrayList polls = titleList();
for (int i = 0; i < polls.size(); i++){
String pollKey = name + "-" + polls.get(i).toString();
String pollKey = "poll:" + name + ":" + polls.get(i).toString();
Poll doomedPoll = getPoll(pollKey);
if (doomedPoll.publishToWeb){
cutOffWebPoll(pollKey);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public ArrayList <String> titleList()
Jedis jedis = PollApplication.dbConnect();
String roomName = Red5.getConnectionLocal().getScope().getName();
ArrayList <String> pollTitleList = new ArrayList <String>();
for (String s : jedis.keys(roomName+"*"))
for (String s : jedis.keys("poll:"+roomName+":*"))
{
pollTitleList.add(jedis.hget(s, "title"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,23 +54,26 @@ public void setRedisPool(JedisPool pool) {
public void record(Poll poll) {
Jedis jedis = PollApplication.dbConnect();
// Merges the poll title, room into a single string seperated by a hyphen
String pollKey = poll.room + "-" + poll.title;
String pollKey = "poll:" + poll.room + ":" + poll.title;
// Saves all relevant information about the poll as fields in a hash
jedis.hset(pollKey, "title", poll.title);
jedis.hset(pollKey, "question", poll.question);
jedis.hset(pollKey, "multiple", poll.isMultiple.toString());
Integer numAnswers = poll.answers.size();
String numAnswersStr = numAnswers.toString();
jedis.hset(pollKey, "numAnswers", numAnswersStr );
jedis.hset(pollKey, "room", poll.room);
jedis.hset(pollKey, "time", poll.time);
// Dynamically creates enough fields in the hash to store all of the answers and their corresponding votes.
// If the poll is freshly created and has no votes yet, the votes are initialized at zero;
// otherwise it fetches the previous number of votes.
for (int i = 1; i <= poll.answers.size(); i++)
{
jedis.hset(pollKey, "answer"+i+"text", poll.answers.toArray()[i-1].toString());
jedis.hset(pollKey, "answer:"+i+":text", poll.answers.toArray()[i-1].toString());
if (poll.votes == null){
jedis.hset(pollKey, "answer"+i, "0");
jedis.hset(pollKey, "answer:"+i, "0");
}else{
jedis.hset(pollKey, "answer"+i, poll.votes.toArray()[i-1].toString());
jedis.hset(pollKey, "answer:"+i, poll.votes.toArray()[i-1].toString());
}
}
Integer tv = poll.totalVotes;
Expand Down Expand Up @@ -99,7 +102,7 @@ public void vote(String pollKey, Poll poll, Object[] answerIDs, Boolean webVote)
// Extract the index value stored at element i of answerIDs
Integer index = Integer.parseInt(answerIDs[i].toString()) + 1;
// Increment the votes for answer
jedis.hincrBy(pollKey, "answer"+index, 1);
jedis.hincrBy(pollKey, "answer:"+index, 1);
}
if (answerIDs.length > 0){
if (!webVote)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,14 @@ package org.bigbluebutton.modules.polling.managers

public function handleVoteEvent(e:VoteEvent):void
{
e.pollKey = module.getRoom() +"-"+ e.title;
e.pollKey = "poll:" + module.getRoom() +":"+ e.title;
service.vote(e.pollKey, e.answerID);
}

public function handleGenerateWebKeyEvent(e:GenerateWebKeyEvent):void
{
e.poll.room = module.getRoom();
e.pollKey = e.poll.room +"-"+ e.poll.title;
e.pollKey = "poll:" + e.poll.room +":"+ e.poll.title;
service.generate(e);
}

Expand All @@ -185,7 +185,7 @@ package org.bigbluebutton.modules.polling.managers

public function handleGetPollingStats(e:PollRefreshEvent):void{
e.poll.room = module.getRoom();
e.pollKey = e.poll.room +"-"+ e.poll.title ;
e.pollKey = "poll:" + e.poll.room +":"+ e.poll.title ;
service.getPoll(e.pollKey, "refresh");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ package org.bigbluebutton.modules.polling.service
}

public function publish(poll:PollObject):void{
var pollKey:String = poll.room + "-" + poll.title;
var pollKey:String = "poll:" + poll.room + ":" + poll.title;
var webKey:String = poll.webKey;
var serverPoll:Array = buildServerPoll(poll);
nc.call("poll.publish", new Responder(success, failure), serverPoll, pollKey);
Expand Down Expand Up @@ -247,7 +247,7 @@ package org.bigbluebutton.modules.polling.service
}

public function cutOffWebPoll(poll:PollObject):void{
var pollKey:String = poll.room+"-"+poll.title;
var pollKey:String = "poll:" + poll.room+":"+poll.title;
nc.call("poll.cutOffWebPoll", new Responder(success, failure), pollKey);
//--------------------------------------//
// Responder functions
Expand Down Expand Up @@ -341,7 +341,7 @@ package org.bigbluebutton.modules.polling.service
event.titleList = obj as Array;
// Append roomID to each item in titleList, call getPoll on that key, add the result to pollList back in ToolBarButton
for (var i:int = 0; i < event.titleList.length; i++){
var pollKey:String = roomID +"-"+ event.titleList[i];
var pollKey:String = "poll:" + roomID +":"+ event.titleList[i];
getPoll(pollKey, "initialize");
}
// This dispatch populates the titleList back in the Menu; the pollList is populated one item at a time in the for-loop
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
myMenuData.addItem(new ValueObject("create", ResourceUtil.getInstance().getString('bbb.polling.createPoll')));
for (var i:int = 0; i < pollList.length; i++){
if (pollList[i] != null){
var keyString:String = pollList[i].room +"-"+ pollList[i].title;
var keyString:String = "poll:" + pollList[i].room +":"+ pollList[i].title;
var menuEntry:ValueObject = new ValueObject(keyString, pollList[i].title);
menuEntry.poll = pollList[i];
if (!pollList[i].status){
Expand Down Expand Up @@ -152,4 +152,4 @@
}
]]>
</mx:Script>
</mx:Button>
</mx:Button>