Skip to content

Commit

Permalink
work on getMeetingInfo API call
Browse files Browse the repository at this point in the history
git-svn-id: http://bigbluebutton.googlecode.com/svn/trunk@3795 af16638f-c34d-0410-8cfa-b39d5352b314
  • Loading branch information
jthomerson committed Mar 4, 2010
1 parent d0df271 commit bdb9832
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ public class Room implements Serializable {
private static Logger log = LoggerFactory.getLogger(Room.class)

private final String name
private final Map <Long, Participant> participants
private final Map <Long, Participant> participants

// these should stay transient so they're not serialized in ActiveMQ messages:
private transient final Map <Long, Participant> unmodifiableMap
private transient final Map<String, IRoomListener> listeners

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import org.apache.commons.lang.StringUtils;

import org.bigbluebutton.web.services.DynamicConferenceService;
import org.bigbluebutton.api.domain.DynamicConference;
import org.bigbluebutton.conference.Room

import org.codehaus.groovy.grails.commons.ConfigurationHolder;

Expand Down Expand Up @@ -64,8 +65,7 @@ class ApiController {
log.debug CONTROLLER_NAME + "#create"

if (!doChecksumSecurity()) {
invalid("checksumError", "You did not pass the checksum security check")
return
invalidChecksum(); return;
}

String name = params.name
Expand Down Expand Up @@ -160,8 +160,7 @@ class ApiController {
log.debug CONTROLLER_NAME + "#join"

if (!doChecksumSecurity()) {
invalid("checksumError", "You did not pass the checksum security check")
return
invalidChecksum(); return;
}

String fullName = params.fullName
Expand Down Expand Up @@ -215,13 +214,11 @@ class ApiController {
log.debug CONTROLLER_NAME + "#isMeetingRunning"

if (!doChecksumSecurity()) {
invalid("checksumError", "You did not pass the checksum security check")
return
invalidChecksum(); return;
}

String mtgToken = params.meetingToken
String mtgID = params.meetingID
String attPW = params.password

// check for existing:
DynamicConference conf = dynamicConferenceService.findConference(mtgToken, mtgID);
Expand All @@ -239,16 +236,36 @@ class ApiController {
}
}

def listAttendees = {
invalid("notImplemented", "This call is not yet implemented.")
}

def endMeeting = {
log.debug CONTROLLER_NAME + "#endMeeting"

if (!doChecksumSecurity()) {
invalidChecksum(); return;
}

invalid("notImplemented", "This call is not yet implemented.")
}

def getMeetingInfo = {
invalid("notImplemented", "This call is not yet implemented.")
log.debug CONTROLLER_NAME + "#getMeetingInfo"

if (!doChecksumSecurity()) {
invalidChecksum(); return;
}

String mtgToken = params.meetingToken
String mtgID = params.meetingID

// check for existing:
DynamicConference conf = dynamicConferenceService.findConference(mtgToken, mtgID);
Room room = dynamicConferenceService.findRoom(mtgToken, mtgID);

if (conf == null || room == null) {
invalid("notFound", "We could not find a meeting with that token or ID");
return;
}

respondWithConferenceDetails(conf, room, null, null);
}

/* helper methods */
Expand Down Expand Up @@ -298,6 +315,26 @@ class ApiController {
}
}

def respondWithConferenceDetails(conf, room, msgKey, msg) {
response.addHeader("Cache-Control", "no-cache")
withFormat {
xml {
render(contentType:"text/xml") {
response() {
returncode(RESP_CODE_SUCCESS)
meetingToken("${conf.meetingToken}")
meetingID("${conf.meetingID}")
attendeePW("${conf.attendeePassword}")
moderatorPW("${conf.moderatorPassword}")
running(conf.isRunning() ? "true" : "false")
messageKey(msgKey == null ? "" : msgKey)
message(msg == null ? "" : msg)
}
}
}
}
}

def respondWithConference(conf, msgKey, msg) {
response.addHeader("Cache-Control", "no-cache")
withFormat {
Expand Down Expand Up @@ -330,6 +367,10 @@ class ApiController {
}
}

def invalidChecksum() {
invalid("checksumError", "You did not pass the checksum security check")
}

def invalid(key, msg) {
log.debug CONTROLLER_NAME + "#invalid"
response.addHeader("Cache-Control", "no-cache")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@
*/
package org.bigbluebutton.web.services

import org.bigbluebutton.conference.Room;
import org.bigbluebutton.conference.Room
import java.util.concurrent.ConcurrentHashMap
import org.apache.commons.collections.bidimap.DualHashBidiMap
import java.util.Collection
import org.bigbluebutton.api.domain.DynamicConference;

Expand All @@ -34,19 +35,41 @@ public class DynamicConferenceService {
def testVoiceBridge
def testConferenceMock

// TODO: need to remove use of DynamicConference and make it use "Room.groovy" instead
// so that both apps and web are using common domain objects and we don't map between them
private final Map<String, Room> roomsByToken
private final Map<String, DynamicConference> confsByMtgID
private final Map<String, String> tokenMap

public DynamicConferenceService() {
confsByMtgID = new ConcurrentHashMap<String, DynamicConference>()
tokenMap = new ConcurrentHashMap<String, String>()
tokenMap = new DualHashBidiMap<String, String>()
roomsByToken = new ConcurrentHashMap<String, Room>()
}

public void storeConference(DynamicConference conf) {
confsByMtgID.put(conf.getMeetingID(), conf);
tokenMap.put(conf.getMeetingToken(), conf.getMeetingID());
}

public Room getRoomByMeetingID(String meetingID) {
if (meetingID == null) {
return null;
}
String token = tokenMap.getKey(meetingID);
if (token == null) {
return null;
}
return roomsByToken.get(token);
}

public Room getRoomByToken(String token) {
if (token == null) {
return null;
}
return roomsByToken.get(token);
}

public DynamicConference getConferenceByMeetingID(String meetingID) {
if (meetingID == null) {
return null;
Expand All @@ -73,9 +96,31 @@ public class DynamicConferenceService {
return conf;
}

public Room findRoom(String token, String mtgID) {
Room room = getRoomByToken(token);
if (room == null) {
room = getRoomByMeetingID(mtgID);
}
return room;
}

public boolean isMeetingWithVoiceBridgeExist(String voiceBridge) {
Collection<DynamicConference> confs = confsByMtgID.values()
for (DynamicConference c : confs) {
if (voiceBridge == c.voiceBridge) {
log.debug "Found voice bridge $voiceBridge"
return true
}
}
log.debug "could not find voice bridge $voiceBridge"
return false
}


// these methods called by spring integration:
public void conferenceStarted(Room room) {
log.debug "conference started: " + room.getName();
participantsUpdated(room);
DynamicConference conf = getConferenceByToken(room.getName());
if (conf != null) {
conf.setStartTime(new Date());
Expand All @@ -93,15 +138,10 @@ public class DynamicConferenceService {
}
}

public boolean isMeetingWithVoiceBridgeExist(String voiceBridge) {
Collection<DynamicConference> confs = confsByMtgID.values()
for (DynamicConference c : confs) {
if (voiceBridge == c.voiceBridge) {
log.debug "Found voice bridge $voiceBridge"
return true
}
}
log.debug "could not find voice bridge $voiceBridge"
return false
public void participantsUpdated(Room room) {
log.debug "participants updated: " + room.getName();
roomsByToken.put(room.getName(), room);
}
// end of spring integration-called methods

}

0 comments on commit bdb9832

Please sign in to comment.