From 500604eb55bf2df06bc74c1982a0dc33889439fb Mon Sep 17 00:00:00 2001 From: Jeremy Thomerson Date: Thu, 4 Mar 2010 23:59:02 +0000 Subject: [PATCH] getMeetingInfo API call working now just need to add more information to it git-svn-id: http://bigbluebutton.googlecode.com/svn/trunk@3796 af16638f-c34d-0410-8cfa-b39d5352b314 --- .../conference/Participant.groovy | 4 ++ .../org/bigbluebutton/conference/Room.groovy | 12 +++++ .../IConferenceEventListener.groovy | 9 ++-- .../ParticipantUpdatingRoomListener.groovy | 54 +++++++++++++++++++ .../conference/RoomsManager.groovy | 17 ++++-- .../src/main/webapp/WEB-INF/bbb-apps.xml | 7 +++ .../grails-app/conf/spring/resources.xml | 10 ++++ .../web/controllers/ApiController.groovy | 2 + 8 files changed, 106 insertions(+), 9 deletions(-) create mode 100644 bigbluebutton-apps/src/main/groovy/org/bigbluebutton/conference/ParticipantUpdatingRoomListener.groovy diff --git a/bbb-common-message/src/main/groovy/org/bigbluebutton/conference/Participant.groovy b/bbb-common-message/src/main/groovy/org/bigbluebutton/conference/Participant.groovy index c2143897ef..f86359bd0c 100644 --- a/bbb-common-message/src/main/groovy/org/bigbluebutton/conference/Participant.groovy +++ b/bbb-common-message/src/main/groovy/org/bigbluebutton/conference/Participant.groovy @@ -40,6 +40,10 @@ import java.lang.Long unmodifiableStatus = Collections.unmodifiableMap(status) } + public boolean isModerator() { + return "MODERATOR".equals(role); + } + public String getName() { return name } diff --git a/bbb-common-message/src/main/groovy/org/bigbluebutton/conference/Room.groovy b/bbb-common-message/src/main/groovy/org/bigbluebutton/conference/Room.groovy index 216dbb23fc..4f12f6e003 100644 --- a/bbb-common-message/src/main/groovy/org/bigbluebutton/conference/Room.groovy +++ b/bbb-common-message/src/main/groovy/org/bigbluebutton/conference/Room.groovy @@ -132,4 +132,16 @@ public class Room implements Serializable { return participants.size() } + public int getNumberOfModerators() { + int sum = 0; + for (Iterator it = participants.values().iterator(); it.hasNext(); ) { + Participant part = it.next(); + if (part.isModerator()) { + sum++; + } + } + log.debug("Returning number of moderators: " + sum) + return sum; + } + } diff --git a/bigbluebutton-apps/src/main/groovy/org/bigbluebutton/conference/IConferenceEventListener.groovy b/bigbluebutton-apps/src/main/groovy/org/bigbluebutton/conference/IConferenceEventListener.groovy index a1a7fe7a0a..840e5e6510 100644 --- a/bigbluebutton-apps/src/main/groovy/org/bigbluebutton/conference/IConferenceEventListener.groovy +++ b/bigbluebutton-apps/src/main/groovy/org/bigbluebutton/conference/IConferenceEventListener.groovy @@ -34,10 +34,7 @@ public interface IConferenceEventListener { @Gateway(requestChannel="conferenceEnded") void ended(Room room); - - /* - void participantJoined(Room room, Participant participant); - - void participantLeft(Room room, Participant participant); - */ + + @Gateway(requestChannel="participantsUpdated") + void participantsUpdated(Room room); } diff --git a/bigbluebutton-apps/src/main/groovy/org/bigbluebutton/conference/ParticipantUpdatingRoomListener.groovy b/bigbluebutton-apps/src/main/groovy/org/bigbluebutton/conference/ParticipantUpdatingRoomListener.groovy new file mode 100644 index 0000000000..95281f113b --- /dev/null +++ b/bigbluebutton-apps/src/main/groovy/org/bigbluebutton/conference/ParticipantUpdatingRoomListener.groovy @@ -0,0 +1,54 @@ +/* + * BigBlueButton - http://www.bigbluebutton.org + * + * Copyright (c) 2008-2009 by respective authors (see below). All rights reserved. + * + * BigBlueButton is free software; you can redistribute it and/or modify it under the + * terms of the GNU Lesser General Public License as published by the Free Software + * Foundation; either version 3 of the License, or (at your option) any later + * version. + * + * BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along + * with BigBlueButton; if not, If not, see . + * + * $Id: $ + */ + +package org.bigbluebutton.conference + +public class ParticipantUpdatingRoomListener implements IRoomListener{ + + private IConferenceEventListener conferenceEventListener; + private Room room; + + public ParticipantUpdatingRoomListener(IConferenceEventListener lstnr, Room room) { + this.conferenceEventListener = lstnr; + this.room = room; + } + + def getName() { + return 'TEMPNAME' + } + + public void participantStatusChange(Long userid, String status, Object value){ + if (conferenceEventListener != null) { + conferenceEventListener.participantsUpdated(room); + } + } + + public void participantJoined(Participant p) { + if (conferenceEventListener != null) { + conferenceEventListener.participantsUpdated(room); + } + } + + public void participantLeft(Long userid) { + if (conferenceEventListener != null) { + conferenceEventListener.participantsUpdated(room); + } + } +} diff --git a/bigbluebutton-apps/src/main/groovy/org/bigbluebutton/conference/RoomsManager.groovy b/bigbluebutton-apps/src/main/groovy/org/bigbluebutton/conference/RoomsManager.groovy index d3735557fe..c781b8a0d7 100644 --- a/bigbluebutton-apps/src/main/groovy/org/bigbluebutton/conference/RoomsManager.groovy +++ b/bigbluebutton-apps/src/main/groovy/org/bigbluebutton/conference/RoomsManager.groovy @@ -41,8 +41,10 @@ public class RoomsManager { rooms = new ConcurrentHashMap() } - public void addRoom(Room room) { + public void addRoom(final Room room) { log.debug("In RoomsManager adding room ${room.name}") + room.addRoomListener(new ParticipantUpdatingRoomListener(conferenceEventListener, room)); + if (checkEvtListener()) { conferenceEventListener.started(room) log.debug("notified event listener of conference start") @@ -60,7 +62,6 @@ public class RoomsManager { } private boolean checkEvtListener() { - println "RoomsManager event listener: " + conferenceEventListener log.debug("RoomsManager event listener: " + conferenceEventListener) return conferenceEventListener != null; } @@ -110,11 +111,18 @@ public class RoomsManager { } log.warn("Removing listener from a non-existing room ${roomName}") } - + public void addParticipant(String roomName, Participant participant) { log.debug("In RoomsManager - ${roomName} add participant ${participant.name}") Room r = getRoom(roomName) if (r != null) { + if (checkEvtListener()) { + conferenceEventListener.participantsUpdated(room); + if (r.getNumberOfParticipants() == 0) { + conferenceEventListener.started(room) + log.debug("notified event listener of conference start") + } + } r.addParticipant(participant) return } @@ -125,6 +133,9 @@ public class RoomsManager { log.debug("In RoomsManager - ${roomName} remove participant ${participant.name}") Room r = getRoom(roomName) if (r != null) { + if (checkEvtListener()) { + conferenceEventListener.participantsUpdated(room); + } r.removeParticipant(userid) return } diff --git a/bigbluebutton-apps/src/main/webapp/WEB-INF/bbb-apps.xml b/bigbluebutton-apps/src/main/webapp/WEB-INF/bbb-apps.xml index e704d8803a..dfcf8b381b 100644 --- a/bigbluebutton-apps/src/main/webapp/WEB-INF/bbb-apps.xml +++ b/bigbluebutton-apps/src/main/webapp/WEB-INF/bbb-apps.xml @@ -137,4 +137,11 @@ + + + + + + + diff --git a/bigbluebutton-web/grails-app/conf/spring/resources.xml b/bigbluebutton-web/grails-app/conf/spring/resources.xml index eba9dc54f4..f2fb3957da 100644 --- a/bigbluebutton-web/grails-app/conf/spring/resources.xml +++ b/bigbluebutton-web/grails-app/conf/spring/resources.xml @@ -63,12 +63,22 @@ + + + + + + + diff --git a/bigbluebutton-web/grails-app/controllers/org/bigbluebutton/web/controllers/ApiController.groovy b/bigbluebutton-web/grails-app/controllers/org/bigbluebutton/web/controllers/ApiController.groovy index 60f9aaa47c..92ee7d205d 100644 --- a/bigbluebutton-web/grails-app/controllers/org/bigbluebutton/web/controllers/ApiController.groovy +++ b/bigbluebutton-web/grails-app/controllers/org/bigbluebutton/web/controllers/ApiController.groovy @@ -327,6 +327,8 @@ class ApiController { attendeePW("${conf.attendeePassword}") moderatorPW("${conf.moderatorPassword}") running(conf.isRunning() ? "true" : "false") + participantCount(room.getNumberOfParticipants()) + moderatorCount(room.getNumberOfModerators()) messageKey(msgKey == null ? "" : msgKey) message(msg == null ? "" : msg) }