Merge pull request #4205 from ritzalam/breakout-time-remaining

- display breakout room time remaining
This commit is contained in:
Richard Alam 2017-08-04 12:34:19 -04:00 committed by GitHub
commit 5cfc55eb94
5 changed files with 91 additions and 7 deletions

View File

@ -0,0 +1,64 @@
/**
* BigBlueButton open source conferencing system - http://www.bigbluebutton.org/
*
* Copyright (c) 2016 BigBlueButton Inc. and by respective authors (see below).
*
* This program 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.0 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, see <http://www.gnu.org/licenses/>.
*
*/
package org.bigbluebutton.core {
import flash.events.TimerEvent;
import flash.utils.Dictionary;
import flash.utils.Timer;
import mx.controls.Label;
import org.bigbluebutton.util.i18n.ResourceUtil;
public final class BreakoutTimerUtil {
public static var timers:Dictionary = new Dictionary(true);
public static function setCountDownTimer(label:Label, seconds:int):void {
var timer:Timer = getTimer(label.id, seconds);
if (!timer.hasEventListener(TimerEvent.TIMER)) {
timer.addEventListener(TimerEvent.TIMER, function():void {
var remainingSeconds:int = timer.repeatCount - timer.currentCount;
var formattedTime:String = (Math.floor(remainingSeconds / 60)) + ":" + (remainingSeconds % 60 >= 10 ? "" : "0") + (remainingSeconds % 60);
label.htmlText = ResourceUtil.getInstance().getString('bbb.users.breakout.timer', [formattedTime]);
});
timer.addEventListener(TimerEvent.TIMER_COMPLETE, function():void {
label.text = ResourceUtil.getInstance().getString('bbb.users.breakout.closing');
});
} else {
timer.stop();
timer.reset();
}
timer.start();
}
public static function getTimer(name:String, defaultRepeatCount:Number):Timer {
if (timers[name] == undefined) {
timers[name] = new Timer(1000, defaultRepeatCount);
}
Timer(timers[name]).repeatCount = defaultRepeatCount;
return timers[name];
}
public static function stopTimer(name:String):void {
if (timers[name] != undefined) {
timers[name].stop();
}
}
}
}

View File

@ -0,0 +1,17 @@
package org.bigbluebutton.core.events
{
import flash.events.Event;
public class MeetingTimeRemainingEvent extends Event
{
public static const TIME_REMAINING:String = "meeting time remaining event";
public var timeLeftInSec:int;
public function MeetingTimeRemainingEvent(timeLeftInSec:int)
{
super(TIME_REMAINING, false, false);
this.timeLeftInSec = timeLeftInSec;
}
}
}

View File

@ -49,7 +49,7 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
<mate:Listener type="{SuccessfulLoginEvent.USER_LOGGED_IN}" method="refreshModeratorButtonsVisibility" />
<mate:Listener type="{ChangeMyRole.CHANGE_MY_ROLE_EVENT}" method="refreshRole" />
<mate:Listener type="{BBBEvent.CONFIRM_LOGOUT_END_MEETING_EVENT}" method="confirmEndSession" />
<mate:Listener type="{BreakoutRoomEvent.UPDATE_REMAINING_TIME_PARENT}" method="handleRemainingTimeUpdate" />
<mate:Listener type="{MeetingTimeRemainingEvent.TIME_REMAINING}" method="handleRemainingTimeUpdate" />
</fx:Declarations>
<fx:Script>
<![CDATA[
@ -63,6 +63,7 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
import mx.events.CloseEvent;
import mx.events.ToolTipEvent;
import mx.managers.PopUpManager;
import org.as3commons.lang.StringUtils;
import org.as3commons.logging.api.ILogger;
import org.as3commons.logging.api.getClassLogger;
@ -73,6 +74,7 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
import org.bigbluebutton.core.Options;
import org.bigbluebutton.core.TimerUtil;
import org.bigbluebutton.core.UsersUtil;
import org.bigbluebutton.core.events.MeetingTimeRemainingEvent;
import org.bigbluebutton.core.model.Config;
import org.bigbluebutton.core.model.LiveMeeting;
import org.bigbluebutton.main.events.BBBEvent;
@ -190,12 +192,12 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
}
}
private function handleRemainingTimeUpdate(e:BreakoutRoomEvent):void {
private function handleRemainingTimeUpdate(e:MeetingTimeRemainingEvent):void {
if (! timeRemaining.visible) {
timeRemaining.visible = true;
timeRemainingLabel.visible = true;
}
TimerUtil.setCountDownTimer(timeRemaining, e.durationInMinutes);
TimerUtil.setCountDownTimer(timeRemaining, e.timeLeftInSec);
}
private function retrieveMeetingName(e:ConferenceCreatedEvent):void {

View File

@ -29,6 +29,7 @@ package org.bigbluebutton.modules.users.services
import org.bigbluebutton.core.EventConstants;
import org.bigbluebutton.core.UsersUtil;
import org.bigbluebutton.core.events.CoreEvent;
import org.bigbluebutton.core.events.MeetingTimeRemainingEvent;
import org.bigbluebutton.core.events.NewGuestWaitingEvent;
import org.bigbluebutton.core.events.UserEmojiChangedEvent;
import org.bigbluebutton.core.events.UserStatusChangedEvent;
@ -730,8 +731,7 @@ package org.bigbluebutton.modules.users.services
}
private function handleMeetingTimeRemainingUpdateEvtMsg(msg:Object):void {
var e:BreakoutRoomEvent = new BreakoutRoomEvent(BreakoutRoomEvent.UPDATE_REMAINING_TIME_PARENT);
e.durationInMinutes = msg.body.timeLeftInSec;
var e:MeetingTimeRemainingEvent = new MeetingTimeRemainingEvent(msg.body.timeLeftInSec);
dispatcher.dispatchEvent(e);
}

View File

@ -86,6 +86,7 @@ $Id: $
import org.bigbluebutton.common.IBbbModuleWindow;
import org.bigbluebutton.common.Role;
import org.bigbluebutton.common.events.LocaleChangeEvent;
import org.bigbluebutton.core.BreakoutTimerUtil;
import org.bigbluebutton.core.EventConstants;
import org.bigbluebutton.core.KeyboardUtil;
import org.bigbluebutton.core.PopUpUtil;
@ -448,7 +449,7 @@ $Id: $
}
private function handleRemainingTimeUpdate(event:BreakoutRoomEvent):void {
TimerUtil.setCountDownTimer(breakoutTimeLabel, event.durationInMinutes);
BreakoutTimerUtil.setCountDownTimer(breakoutTimeLabel, event.durationInMinutes);
}
private function breakoutRoomsListChangeListener(event:CollectionEvent):void {