Merge branch '081-network-monitor' into 090-network-monitor

Conflicts:
	bigbluebutton-client/src/org/bigbluebutton/core/services/BandwidthMonitor.as
	bigbluebutton-client/src/org/bigbluebutton/main/model/users/NetConnectionDelegate.as
	bigbluebutton-client/src/org/bigbluebutton/main/views/MainApplicationShell.mxml
This commit is contained in:
Mateus Dalepiane 2014-09-11 12:26:36 -03:00
commit ba020a8e52
13 changed files with 333 additions and 220 deletions

View File

@ -320,6 +320,15 @@ bbb.settings.warning.label = Warning
bbb.settings.warning.close = Close this Warning bbb.settings.warning.close = Close this Warning
bbb.settings.noissues = No outstanding issues have been detected. bbb.settings.noissues = No outstanding issues have been detected.
bbb.settings.instructions = Accept the Flash prompt that asks you for webcam permissions. If the output matches what is expected, your browser has been set up correctly. Other potentials issues are below. Examine them to find a possible solution. bbb.settings.instructions = Accept the Flash prompt that asks you for webcam permissions. If the output matches what is expected, your browser has been set up correctly. Other potentials issues are below. Examine them to find a possible solution.
bbb.bwmonitor.title = Network monitor
bbb.bwmonitor.upload = Upload
bbb.bwmonitor.upload.short = Up
bbb.bwmonitor.download = Download
bbb.bwmonitor.download.short = Down
bbb.bwmonitor.total = Total
bbb.bwmonitor.current = Current
bbb.bwmonitor.available = Available
bbb.bwmonitor.latency = Latency
ltbcustom.bbb.highlighter.toolbar.triangle = Triangle ltbcustom.bbb.highlighter.toolbar.triangle = Triangle
ltbcustom.bbb.highlighter.toolbar.triangle.accessibilityName = Switch whiteboard cursor to triangle ltbcustom.bbb.highlighter.toolbar.triangle.accessibilityName = Switch whiteboard cursor to triangle
ltbcustom.bbb.highlighter.toolbar.line = Line ltbcustom.bbb.highlighter.toolbar.line = Line

View File

@ -320,6 +320,15 @@ bbb.settings.warning.label = Aviso
bbb.settings.warning.close = Fechar esse aviso bbb.settings.warning.close = Fechar esse aviso
bbb.settings.noissues = Nenhum problema foi detectado. bbb.settings.noissues = Nenhum problema foi detectado.
bbb.settings.instructions = Aceite a notificação do Flash quando ele requisitar permissão para acessar sua câmera. Se você consegue ver e ouvir a si mesmo, seu navegador foi configurado corretamente. Outros erros em potencial estão indicados abaixo. Verifique cada um para encontrar uma possível solução. bbb.settings.instructions = Aceite a notificação do Flash quando ele requisitar permissão para acessar sua câmera. Se você consegue ver e ouvir a si mesmo, seu navegador foi configurado corretamente. Outros erros em potencial estão indicados abaixo. Verifique cada um para encontrar uma possível solução.
bbb.bwmonitor.title = Monitor de rede
bbb.bwmonitor.upload = Upload
bbb.bwmonitor.upload.short = Up
bbb.bwmonitor.download = Download
bbb.bwmonitor.download.short = Down
bbb.bwmonitor.total = Total
bbb.bwmonitor.current = Atual
bbb.bwmonitor.available = Disponível
bbb.bwmonitor.latency = Latência
ltbcustom.bbb.highlighter.toolbar.triangle = Triângulo ltbcustom.bbb.highlighter.toolbar.triangle = Triângulo
ltbcustom.bbb.highlighter.toolbar.triangle.accessibilityName = Mudar o cursor do quadro branco para triângulo ltbcustom.bbb.highlighter.toolbar.triangle.accessibilityName = Mudar o cursor do quadro branco para triângulo
ltbcustom.bbb.highlighter.toolbar.line = Linha ltbcustom.bbb.highlighter.toolbar.line = Linha

View File

@ -306,5 +306,8 @@ package org.bigbluebutton.common
[Embed(source="assets/images/grid_icon.png")] [Embed(source="assets/images/grid_icon.png")]
public var grid_icon:Class; public var grid_icon:Class;
[Embed(source="assets/images/arrow_refresh_small.png")]
public var refreshSmall:Class;
} }
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 506 B

View File

@ -19,6 +19,7 @@
package org.bigbluebutton.core.services package org.bigbluebutton.core.services
{ {
import flash.events.AsyncErrorEvent; import flash.events.AsyncErrorEvent;
import flash.events.IOErrorEvent;
import flash.events.NetStatusEvent; import flash.events.NetStatusEvent;
import flash.events.TimerEvent; import flash.events.TimerEvent;
import flash.net.NetConnection; import flash.net.NetConnection;
@ -34,131 +35,186 @@ package org.bigbluebutton.core.services
import org.red5.flash.bwcheck.events.BandwidthDetectEvent; import org.red5.flash.bwcheck.events.BandwidthDetectEvent;
public class BandwidthMonitor { public class BandwidthMonitor {
public static const INTERVAL_BETWEEN_CHECKS:int = 30000; // in ms
private static var _instance:BandwidthMonitor = null;
private var _serverURL:String = "localhost"; private var _serverURL:String = "localhost";
private var _serverApplication:String = "video"; private var _serverApplication:String = "video";
private var _clientServerService:String = "checkBandwidthUp"; private var _clientServerService:String = "checkBandwidthUp";
private var _serverClientService:String = "checkBandwidth"; private var _serverClientService:String = "checkBandwidth";
private var nc:NetConnection; private var _pendingClientToServer:Boolean;
private var _pendingServerToClient:Boolean;
private var _lastClientToServerCheck:Date;
private var _lastServerToClientCheck:Date;
private var _runningMeasurement:Boolean;
private var _connecting:Boolean;
private var _nc:NetConnection;
private var bwTestTimer:Timer; /**
* This class is a singleton. Please initialize it using the getInstance() method.
*/
public function BandwidthMonitor(enforcer:SingletonEnforcer) {
if (enforcer == null) {
throw new Error("There can only be one instance of this class");
}
initialize();
}
public function BandwidthMonitor() { private function initialize():void {
_pendingClientToServer = false;
_pendingServerToClient = false;
_runningMeasurement = false;
_connecting = false;
_lastClientToServerCheck = null;
_lastServerToClientCheck = null;
_nc = new NetConnection();
_nc.objectEncoding = flash.net.ObjectEncoding.AMF0;
_nc.client = this;
_nc.addEventListener(NetStatusEvent.NET_STATUS, onStatus);
_nc.addEventListener(AsyncErrorEvent.ASYNC_ERROR, onAsyncError);
_nc.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
}
/**
* Return the single instance of this class
*/
public static function getInstance():BandwidthMonitor {
if (_instance == null) {
_instance = new BandwidthMonitor(new SingletonEnforcer());
}
return _instance;
} }
public function set serverURL(url:String):void { public function set serverURL(url:String):void {
if (_nc.connected)
_nc.close();
_serverURL = url; _serverURL = url;
} }
public function set serverApplication(app:String):void { public function set serverApplication(app:String):void {
if (_nc.connected)
_nc.close();
_serverApplication = app; _serverApplication = app;
} }
public function start():void {
connect();
}
private function connect():void { private function connect():void {
nc = new NetConnection(); if (!_nc.connected && !_connecting) {
nc.objectEncoding = flash.net.ObjectEncoding.AMF0; _nc.connect("rtmp://" + _serverURL + "/" + _serverApplication);
nc.proxyType = "best"; _connecting = true;
nc.client = this; }
nc.addEventListener(NetStatusEvent.NET_STATUS, onStatus);
nc.addEventListener(AsyncErrorEvent.ASYNC_ERROR, onAsyncError);
nc.connect("rtmp://" + _serverURL + "/" + _serverApplication);
} }
private function onAsyncError(event:AsyncErrorEvent):void public function checkClientToServer():void {
{ if (_lastClientToServerCheck != null && _lastClientToServerCheck.getTime() + INTERVAL_BETWEEN_CHECKS > new Date().getTime())
return;
if (!_nc.connected) {
_pendingClientToServer = true;
connect();
} if (_runningMeasurement) {
_pendingClientToServer = true;
} else {
_pendingClientToServer = false;
_runningMeasurement = true;
_lastClientToServerCheck = new Date();
LogUtil.debug("Start client-server bandwidth detection");
var clientServer:ClientServerBandwidth = new ClientServerBandwidth();
clientServer.connection = _nc;
clientServer.service = _clientServerService;
clientServer.addEventListener(BandwidthDetectEvent.DETECT_COMPLETE,onClientServerComplete);
clientServer.addEventListener(BandwidthDetectEvent.DETECT_STATUS,onClientServerStatus);
clientServer.addEventListener(BandwidthDetectEvent.DETECT_FAILED,onDetectFailed);
clientServer.start();
}
}
public function checkServerToClient():void {
if (_lastServerToClientCheck != null && _lastServerToClientCheck.getTime() + INTERVAL_BETWEEN_CHECKS > new Date().getTime())
return;
if (!_nc.connected) {
_pendingServerToClient = true;
connect();
} if (_runningMeasurement) {
_pendingServerToClient = true;
} else {
_pendingServerToClient = false;
_runningMeasurement = true;
_lastServerToClientCheck = new Date();
LogUtil.debug("Start server-client bandwidth detection");
var serverClient:ServerClientBandwidth = new ServerClientBandwidth();
serverClient.connection = _nc;
serverClient.service = _serverClientService;
serverClient.addEventListener(BandwidthDetectEvent.DETECT_COMPLETE,onServerClientComplete);
serverClient.addEventListener(BandwidthDetectEvent.DETECT_STATUS,onServerClientStatus);
serverClient.addEventListener(BandwidthDetectEvent.DETECT_FAILED,onDetectFailed);
serverClient.start();
}
}
private function checkPendingOperations():void {
if (_pendingClientToServer) checkClientToServer();
if (_pendingServerToClient) checkServerToClient();
}
private function onAsyncError(event:AsyncErrorEvent):void {
LogUtil.debug(event.error.toString()); LogUtil.debug(event.error.toString());
} }
private function onIOError(event:IOErrorEvent):void {
LogUtil.debug(event.text);
}
private function onStatus(event:NetStatusEvent):void private function onStatus(event:NetStatusEvent):void
{ {
switch (event.info.code) switch (event.info.code)
{ {
case "NetConnection.Connect.Success": case "NetConnection.Connect.Success":
LogUtil.debug("Starting to monitor bandwidth between client and server"); LogUtil.debug("Starting to monitor bandwidth between client and server");
// monitor();
break; break;
default: default:
LogUtil.debug("Cannot establish the connection to measure bandwidth"); LogUtil.debug("Cannot establish the connection to measure bandwidth");
break; break;
} }
_connecting = false;
checkPendingOperations();
} }
private function monitor():void { public function onDetectFailed(event:BandwidthDetectEvent):void {
LogUtil.debug("Starting to monitor bandwidth");
bwTestTimer = new Timer(30000);
bwTestTimer.addEventListener(TimerEvent.TIMER, rtmptRetryTimerHandler);
bwTestTimer.start();
}
private function rtmptRetryTimerHandler(event:TimerEvent):void {
LogUtil.debug("Starting to detect bandwidth from server to client");
ServerClient();
}
public function ClientServer():void
{
var clientServer:ClientServerBandwidth = new ClientServerBandwidth();
//connect();
clientServer.connection = nc;
clientServer.service = _clientServerService;
clientServer.addEventListener(BandwidthDetectEvent.DETECT_COMPLETE,onClientServerComplete);
clientServer.addEventListener(BandwidthDetectEvent.DETECT_STATUS,onClientServerStatus);
clientServer.addEventListener(BandwidthDetectEvent.DETECT_FAILED,onDetectFailed);
clientServer.start();
}
public function ServerClient():void
{
var serverClient:ServerClientBandwidth = new ServerClientBandwidth();
//connect();
serverClient.connection = nc;
serverClient.service = _serverClientService;
serverClient.addEventListener(BandwidthDetectEvent.DETECT_COMPLETE,onServerClientComplete);
serverClient.addEventListener(BandwidthDetectEvent.DETECT_STATUS,onServerClientStatus);
serverClient.addEventListener(BandwidthDetectEvent.DETECT_FAILED,onDetectFailed);
serverClient.start();
}
public function onDetectFailed(event:BandwidthDetectEvent):void
{
LogUtil.debug("Detection failed with error: " + event.info.application + " " + event.info.description); LogUtil.debug("Detection failed with error: " + event.info.application + " " + event.info.description);
_runningMeasurement = false;
} }
public function onClientServerComplete(event:BandwidthDetectEvent):void public function onClientServerComplete(event:BandwidthDetectEvent):void {
{ LogUtil.debug("Client-server bandwidth detection complete");
// LogUtil.debug("Client-slient bandwidth detect complete");
// LogUtil.debug(ObjectUtil.toString(event.info)); // LogUtil.debug(ObjectUtil.toString(event.info));
NetworkStatsData.getInstance().setUploadMeasuredBW(event.info); NetworkStatsData.getInstance().setUploadMeasuredBW(event.info);
_runningMeasurement = false;
checkPendingOperations();
} }
public function onClientServerStatus(event:BandwidthDetectEvent):void public function onClientServerStatus(event:BandwidthDetectEvent):void {
{ // if (event.info) {
if (event.info) {
// LogUtil.debug("\n count: "+event.info.count+ " sent: "+event.info.sent+" timePassed: "+event.info.timePassed+" latency: "+event.info.latency+" overhead: "+event.info.overhead+" packet interval: " + event.info.pakInterval + " cumLatency: " + event.info.cumLatency); // LogUtil.debug("\n count: "+event.info.count+ " sent: "+event.info.sent+" timePassed: "+event.info.timePassed+" latency: "+event.info.latency+" overhead: "+event.info.overhead+" packet interval: " + event.info.pakInterval + " cumLatency: " + event.info.cumLatency);
} // }
} }
public function onServerClientComplete(event:BandwidthDetectEvent):void public function onServerClientComplete(event:BandwidthDetectEvent):void {
{ LogUtil.debug("Server-client bandwidth detection complete");
// LogUtil.debug("Server-client bandwidth detect complete");
// LogUtil.debug(ObjectUtil.toString(event.info)); // LogUtil.debug(ObjectUtil.toString(event.info));
NetworkStatsData.getInstance().setDownloadMeasuredBW(event.info); NetworkStatsData.getInstance().setDownloadMeasuredBW(event.info);
_runningMeasurement = false;
// LogUtil.debug("Detecting Client Server Bandwidth"); checkPendingOperations();
ClientServer();
} }
public function onServerClientStatus(event:BandwidthDetectEvent):void public function onServerClientStatus(event:BandwidthDetectEvent):void {
{ // if (event.info) {
if (event.info) {
// LogUtil.debug("\n count: "+event.info.count+ " sent: "+event.info.sent+" timePassed: "+event.info.timePassed+" latency: "+event.info.latency+" cumLatency: " + event.info.cumLatency); // LogUtil.debug("\n count: "+event.info.count+ " sent: "+event.info.sent+" timePassed: "+event.info.timePassed+" latency: "+event.info.latency+" cumLatency: " + event.info.cumLatency);
} // }
} }
} }
} }
class SingletonEnforcer{}

View File

@ -131,19 +131,22 @@ package org.bigbluebutton.core.services
var download:Dictionary = new Dictionary(); var download:Dictionary = new Dictionary();
var upload:Dictionary = new Dictionary(); var upload:Dictionary = new Dictionary();
download["byteCount"] = upload["byteCount"]
= download["currentBytesPerSecond"] = upload["currentBytesPerSecond"] = 0;
for (var i:int = 0; i < streams.length; i++) { for (var i:int = 0; i < streams.length; i++) {
if (streams[i] == null || streams[i].info == null) { if (streams[i] == null || streams[i].info == null) {
// stream info is null, returning // stream info is null, returning
continue; continue;
} }
// log("Heartbeat on " + streams[i].info); //log("Heartbeat on " + streams[i].info);
var remote:Boolean = isRemoteStream(streams[i]); var remote:Boolean = isRemoteStream(streams[i]);
var ref:Dictionary = (remote? download: upload); var ref:Dictionary = (remote? download: upload);
if (streams[i].info.uri == null) { if (streams[i].info.uri == null) {
log("Stream URI is null, returning"); //log("Stream URI is null, returning");
continue; continue;
} }
var uri:String = streams[i].info.uri.toLowerCase(); var uri:String = streams[i].info.uri.toLowerCase();
@ -174,7 +177,7 @@ package org.bigbluebutton.core.services
var property:String = s.@name; var property:String = s.@name;
var num:Number = 0; var num:Number = 0;
if (ref.hasOwnProperty(property)) if (ref.hasOwnProperty(property))
num = ref[property] as Number; num = (ref[property] as Number);
num += (streams[i].info[property] as Number); num += (streams[i].info[property] as Number);
ref[property] = num; ref[property] = num;
} }
@ -206,11 +209,6 @@ package org.bigbluebutton.core.services
//log(value.streamName + ": " + value.byteCount); //log(value.streamName + ": " + value.byteCount);
} }
// var netstatsEvent:NetworkStatsEvent = new NetworkStatsEvent();
// netstatsEvent.downloadStats = download;
// netstatsEvent.uploadStats = upload;
// _globalDispatcher.dispatchEvent(netstatsEvent);
NetworkStatsData.getInstance().updateConsumedBW(download["currentBytesPerSecond"], NetworkStatsData.getInstance().updateConsumedBW(download["currentBytesPerSecond"],
upload["currentBytesPerSecond"], upload["currentBytesPerSecond"],
download["byteCount"], download["byteCount"],
@ -224,8 +222,7 @@ package org.bigbluebutton.core.services
} }
private function log(s:String):void { private function log(s:String):void {
//LogUtil.debug("[StreamMonitor] " + s); LogUtil.debug("[StreamMonitor] " + s);
trace("[StreamMonitor] " + s);
} }
} }
} }

View File

@ -30,10 +30,7 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
--> -->
<ObjectBuilder generator="{ModulesProxy}" cache="global" /> <ObjectBuilder generator="{ModulesProxy}" cache="global" />
<ObjectBuilder generator="{ConfigManager}" cache="global" /> <ObjectBuilder generator="{ConfigManager}" cache="global" />
<!-- <ObjectBuilder generator="{StreamMonitor}" cache="global" />
Disabling temporarily the stream monitor
-->
<!--ObjectBuilder generator="{StreamMonitor}" cache="global" /-->
</EventHandlers> </EventHandlers>
<EventHandlers type="{PortTestEvent.TEST_RTMP}" > <EventHandlers type="{PortTestEvent.TEST_RTMP}" >

View File

@ -21,6 +21,8 @@ package org.bigbluebutton.main.model
import com.asfusion.mate.events.Dispatcher; import com.asfusion.mate.events.Dispatcher;
import mx.formatters.NumberFormatter;
import org.bigbluebutton.common.LogUtil; import org.bigbluebutton.common.LogUtil;
import org.bigbluebutton.main.events.NetworkStatsEvent; import org.bigbluebutton.main.events.NetworkStatsEvent;
@ -31,12 +33,15 @@ package org.bigbluebutton.main.model
private static var _instance:NetworkStatsData = null; private static var _instance:NetworkStatsData = null;
private var _currentConsumedDownBW:Number = 0; // Kb private var _currentConsumedDownBW:Number = 0; // Kb
private var _currentConsumedUpBW:Number = 0; // Kb private var _currentConsumedUpBW:Number = 0; // Kb
private var _totalConsumedDownBW:Number = 0; // MB private var _totalConsumedDownBW:Number = 0; // KB
private var _totalConsumedUpBW:Number = 0; // MB private var _totalConsumedUpBW:Number = 0; // KB
private var _measuredDownBW:int = 0; // Mb private var _measuredDownBWCheck:Boolean = false;
private var _measuredDownBW:Number = 0; // Kb
private var _measuredDownLatency:int = 0; // ms private var _measuredDownLatency:int = 0; // ms
private var _measuredUpBW:int = 0; // Mb private var _measuredUpBWCheck:Boolean = false;
private var _measuredUpBW:Number = 0; // Kb
private var _measuredUpLatency:int = 0; // ms private var _measuredUpLatency:int = 0; // ms
private var _numberFormatter:NumberFormatter = new NumberFormatter();
/** /**
* This class is a singleton. Please initialize it using the getInstance() method. * This class is a singleton. Please initialize it using the getInstance() method.
@ -49,6 +54,8 @@ package org.bigbluebutton.main.model
} }
private function initialize():void { private function initialize():void {
_numberFormatter.precision = 1;
_numberFormatter.useThousandsSeparator = true;
} }
/** /**
@ -63,10 +70,10 @@ package org.bigbluebutton.main.model
// all the numbers are in bytes // all the numbers are in bytes
public function updateConsumedBW(down:Number, up:Number, downTotal:Number, upTotal:Number):void { public function updateConsumedBW(down:Number, up:Number, downTotal:Number, upTotal:Number):void {
_currentConsumedDownBW = (down * 8)/1024; _currentConsumedDownBW = (down * 8) / 1024;
_currentConsumedUpBW = (up * 8)/1024; _currentConsumedUpBW = (up * 8) / 1024;
_totalConsumedDownBW = downTotal / 1048576; _totalConsumedDownBW = downTotal / 1024;
_totalConsumedUpBW = upTotal / 1048576; _totalConsumedUpBW = upTotal / 1024;
} }
/* /*
@ -77,7 +84,8 @@ package org.bigbluebutton.main.model
[latency] 10 [latency] 10
*/ */
public function setDownloadMeasuredBW(info:Object):void { public function setDownloadMeasuredBW(info:Object):void {
_measuredDownBW = info["kbitDown"] / 1000; _measuredDownBWCheck = true;
_measuredDownBW = info["kbitDown"];
_measuredDownLatency = info["latency"]; _measuredDownLatency = info["latency"];
} }
@ -90,40 +98,84 @@ package org.bigbluebutton.main.model
latency = 11 latency = 11
*/ */
public function setUploadMeasuredBW(info:Object):void { public function setUploadMeasuredBW(info:Object):void {
_measuredUpBW = info.kbitUp / 1000; _measuredUpBWCheck = true;
_measuredUpBW = info.kbitUp;
_measuredUpLatency = info.latency; _measuredUpLatency = info.latency;
} }
public function get currentConsumedDownBW():Number { private function format_KB(n:Number):String {
return _currentConsumedDownBW; var unit:String = "KB";
if (n >= 1073741824) {
unit = "TB";
n /= 1073741824;
} else if (n >= 1048576) {
unit = "GB";
n /= 1048576;
} else if (n >= 1024) {
unit = "MB";
n /= 1024;
}
return _numberFormatter.format(n) + " " + unit;
} }
public function get currentConsumedUpBW():Number { private function format_Kbps(n:Number):String {
return _currentConsumedUpBW; var unit:String = "Kbps";
if (n >= 1000000000) {
unit = "Tbps";
n /= 1000000000;
} else if (n >= 1000000) {
unit = "Gbps";
n /= 1000000;
} else if (n >= 1000) {
unit = "Mbps";
n /= 1000;
}
return _numberFormatter.format(n) + " " + unit;
} }
public function get totalConsumedDownBW():Number {
return _totalConsumedDownBW; public function get formattedCurrentConsumedDownBW():String {
return format_Kbps(_currentConsumedDownBW);
} }
public function get totalConsumedUpBW():Number { public function get formattedCurrentConsumedUpBW():String {
return _totalConsumedUpBW; return format_Kbps(_currentConsumedUpBW);
} }
public function get measuredDownBW():int { public function get formattedTotalConsumedDownBW():String {
return _measuredDownBW; return format_KB(_totalConsumedDownBW);
} }
public function get measuredDownLatency():int { public function get formattedTotalConsumedUpBW():String {
return _measuredDownLatency; return format_KB(_totalConsumedUpBW);
} }
public function get measuredUpBW():int { public function get formattedMeasuredDownBW():String {
return _measuredUpBW; if (_measuredDownBWCheck)
return format_Kbps(_measuredDownBW);
else
return "-";
} }
public function get measuredUpLatency():int { public function get formattedMeasuredDownLatency():String {
return _measuredUpLatency; if (_measuredDownBWCheck)
return _measuredDownLatency + " ms";
else
return "-";
}
public function get formattedMeasuredUpBW():String {
if (_measuredUpBWCheck)
return format_Kbps(_measuredUpBW);
else
return "-";
}
public function get formattedMeasuredUpLatency():String {
if (_measuredUpBWCheck)
return _measuredUpLatency + " ms";
else
return "-";
} }
} }
} }

View File

@ -74,8 +74,11 @@ package org.bigbluebutton.main.model.users
public function setUri(uri:String):void { public function setUri(uri:String):void {
_applicationURI = uri; _applicationURI = uri;
}
var pattern:RegExp = /(?P<protocol>.+):\/\/(?P<server>.+)\/(?P<app>.+)/;
var result:Array = pattern.exec(uri);
BandwidthMonitor.getInstance().serverURL = result.server;
}
public function get connection():NetConnection { public function get connection():NetConnection {
return _netConnection; return _netConnection;
@ -246,17 +249,6 @@ package org.bigbluebutton.main.model.users
handleResult( event ); handleResult( event );
} }
private var _bwMon:BandwidthMonitor = new BandwidthMonitor();
private function startMonitoringBandwidth():void {
trace("Start monitoring bandwidth.");
var pattern:RegExp = /(?P<protocol>.+):\/\/(?P<server>.+)\/(?P<app>.+)/;
var result:Array = pattern.exec(_applicationURI);
_bwMon.serverURL = result.server;
_bwMon.serverApplication = "video";
_bwMon.start();
}
private var autoReconnectTimer:Timer = new Timer(1000, 1); private var autoReconnectTimer:Timer = new Timer(1000, 1);
public function handleResult(event:Object):void { public function handleResult(event:Object):void {
@ -267,10 +259,7 @@ package org.bigbluebutton.main.model.users
case "NetConnection.Connect.Success": case "NetConnection.Connect.Success":
trace(LOG + ":Connection to viewers application succeeded."); trace(LOG + ":Connection to viewers application succeeded.");
// uncomment this to turn on the bandwidth check
// startMonitoringBandwidth();
validateToken(); validateToken();
break; break;
case "NetConnection.Connect.Failed": case "NetConnection.Connect.Failed":

View File

@ -100,6 +100,7 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
import org.bigbluebutton.main.events.SuccessfulLoginEvent; import org.bigbluebutton.main.events.SuccessfulLoginEvent;
import org.bigbluebutton.main.model.LayoutOptions; import org.bigbluebutton.main.model.LayoutOptions;
import org.bigbluebutton.main.model.users.Conference; import org.bigbluebutton.main.model.users.Conference;
import org.bigbluebutton.main.model.NetworkStatsData;
import org.bigbluebutton.main.model.users.events.ConnectionFailedEvent; import org.bigbluebutton.main.model.users.events.ConnectionFailedEvent;
import org.bigbluebutton.modules.phone.events.AudioSelectionWindowEvent; import org.bigbluebutton.modules.phone.events.AudioSelectionWindowEvent;
import org.bigbluebutton.modules.phone.events.FlashMicSettingsEvent; import org.bigbluebutton.modules.phone.events.FlashMicSettingsEvent;
@ -154,6 +155,9 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
[Bindable] private var isTunneling:Boolean = false; [Bindable] private var isTunneling:Boolean = false;
[Bindable] private var _bandwidthConsumedUp:String = "-";
[Bindable] private var _bandwidthConsumedDown:String = "-";
private var _updateBandwidthTimer:Timer = new Timer(1000);
private var confirmingLogout:Boolean = false; private var confirmingLogout:Boolean = false;
public function initOptions(e:Event):void { public function initOptions(e:Event):void {
@ -175,6 +179,9 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
if (!showFooterOpt) { if (!showFooterOpt) {
footerHeight = 0; footerHeight = 0;
} }
_updateBandwidthTimer.addEventListener(TimerEvent.TIMER, updateBandwidthTimerHandler);
_updateBandwidthTimer.start();
} }
protected function initializeShell():void { protected function initializeShell():void {
@ -526,24 +533,21 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
addedBtns.removeChild(event.button as UIComponent); addedBtns.removeChild(event.button as UIComponent);
} }
private var networkStatsWindow:NetworkStatsWindow = new NetworkStatsWindow(); private var networkStatsWindow:NetworkStatsWindow = null;
private function openNetworkStatsWindow(e:Event = null):void { private function openNetworkStatsWindow():void {
/*var btnPosition:Point = new Point(btnNetwork.x, btnNetwork.y); if (networkStatsWindow == null) {
var btnPositionOnGlobal:Point = btnNetwork.localToGlobal(btnPosition); networkStatsWindow = new NetworkStatsWindow();
var windowPosition:Point = networkStatsWindow.globalToLocal(btnPositionOnGlobal);
windowPosition.x += btnNetwork.width + 10;
windowPosition.y -= networkStatsWindow.height - 10;
networkStatsWindow.x = windowPosition.x;
networkStatsWindow.y = windowPosition.y;*/
networkStatsWindow.appear();
} }
private function closeNetworkStatsWindow(e:Event = null):void { mdiCanvas.windowManager.add(networkStatsWindow);
networkStatsWindow.disappear(); mdiCanvas.windowManager.absPos(networkStatsWindow, mdiCanvas.width - networkStatsWindow.width, mdiCanvas.height - networkStatsWindow.height);
mdiCanvas.windowManager.bringToFront(networkStatsWindow);
}
private function updateBandwidthTimerHandler(e:TimerEvent):void {
_bandwidthConsumedDown = NetworkStatsData.getInstance().formattedCurrentConsumedDownBW;
_bandwidthConsumedUp = NetworkStatsData.getInstance().formattedCurrentConsumedUpBW;
} }
private function openLockSettingsWindow(event:LockControlEvent):void { private function openLockSettingsWindow(event:LockControlEvent):void {
@ -620,6 +624,17 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
icon="{logs_icon}" icon="{logs_icon}"
click="openLogWindow()" click="openLogWindow()"
tabIndex="{baseIndex}"/> tabIndex="{baseIndex}"/>
<mx:Label
text="[{ResourceUtil.getInstance().getString('bbb.bwmonitor.upload.short')}: {_bandwidthConsumedUp} | {ResourceUtil.getInstance().getString('bbb.bwmonitor.download.short')}: {_bandwidthConsumedDown}]"
id="lblNetworkStats"
visible="{layoutOptions.showNetworkMonitor}" />
<mx:Button
id="btnNetwork"
icon="{statsIcon}"
width="20"
height="20"
click="openNetworkStatsWindow()"
visible="{layoutOptions.showNetworkMonitor}" />
<mx:HBox id="addedBtns" /> <mx:HBox id="addedBtns" />
</mx:ControlBar> </mx:ControlBar>
</mx:VBox> </mx:VBox>

View File

@ -23,14 +23,13 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
<MDIWindow xmlns="flexlib.mdi.containers.*" <MDIWindow xmlns="flexlib.mdi.containers.*"
xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:mate="http://mate.asfusion.com/" xmlns:mate="http://mate.asfusion.com/"
title="Network monitor" title="{ResourceUtil.getInstance().getString('bbb.bwmonitor.title')}"
creationComplete="onCreationComplete()" creationComplete="onCreationComplete()"
resizable="false" resizable="false"
showCloseButton="false" showCloseButton="true"
implements="org.bigbluebutton.common.IBbbModuleWindow" implements="org.bigbluebutton.common.IBbbModuleWindow"
width="210" height="261" minHeight="0" minWidth="0" width="210" minWidth="0"
resize="onResize()"> resize="onResize()">
<mx:Script> <mx:Script>
<![CDATA[ <![CDATA[
@ -40,41 +39,43 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
import org.bigbluebutton.common.events.CloseWindowEvent; import org.bigbluebutton.common.events.CloseWindowEvent;
import org.bigbluebutton.common.events.OpenWindowEvent; import org.bigbluebutton.common.events.OpenWindowEvent;
import org.bigbluebutton.common.Images;
import org.bigbluebutton.common.LogUtil; import org.bigbluebutton.common.LogUtil;
import org.bigbluebutton.core.services.BandwidthMonitor;
import org.bigbluebutton.main.model.NetworkStatsData; import org.bigbluebutton.main.model.NetworkStatsData;
import org.bigbluebutton.util.i18n.ResourceUtil;
import mx.core.IFlexDisplayObject;
import mx.effects.Fade; import mx.effects.Fade;
import mx.events.EffectEvent; import mx.events.EffectEvent;
import mx.formatters.NumberFormatter; import mx.managers.PopUpManager;
private var _globalDispatcher:Dispatcher = new Dispatcher(); private var _globalDispatcher:Dispatcher = new Dispatcher();
private var _updateTimer:Timer = new Timer(1000); private var _updateTimer:Timer = new Timer(1000);
private var _numberFormatter:NumberFormatter = new NumberFormatter();
private var _images:Images = new Images();
[Bindable] private var _refreshIcon:Class = _images.refreshSmall;
private function onCreationComplete():void { private function onCreationComplete():void {
this.windowControls.maximizeRestoreBtn.visible = false; this.windowControls.maximizeRestoreBtn.visible = false;
this.windowControls.minimizeBtn.visible = false; this.windowControls.minimizeBtn.visible = false;
this.x = parent.width - this.width;
this.y = parent.height - this.height;
_numberFormatter.precision = 2;
_numberFormatter.useThousandsSeparator = true;
_updateTimer.addEventListener(TimerEvent.TIMER, timerHandler); _updateTimer.addEventListener(TimerEvent.TIMER, timerHandler);
_updateTimer.start(); _updateTimer.start();
height = panel.measuredHeight + borderMetrics.top + borderMetrics.bottom;
} }
private function timerHandler(e:TimerEvent):void { private function timerHandler(e:TimerEvent):void {
labelCurrentDownload.text = _numberFormatter.format(NetworkStatsData.getInstance().currentConsumedDownBW); labelCurrentDownload.text = NetworkStatsData.getInstance().formattedCurrentConsumedDownBW;
labelTotalDownload.text = _numberFormatter.format(NetworkStatsData.getInstance().totalConsumedDownBW); labelTotalDownload.text = NetworkStatsData.getInstance().formattedTotalConsumedDownBW;
labelAvailableDownload.text = _numberFormatter.format(NetworkStatsData.getInstance().measuredDownBW); labelAvailableDownload.text = NetworkStatsData.getInstance().formattedMeasuredDownBW;
labelDownloadLatency.text = String(NetworkStatsData.getInstance().measuredDownLatency); labelDownloadLatency.text = NetworkStatsData.getInstance().formattedMeasuredDownLatency;
labelCurrentUpload.text = _numberFormatter.format(NetworkStatsData.getInstance().currentConsumedUpBW); labelCurrentUpload.text = NetworkStatsData.getInstance().formattedCurrentConsumedUpBW;
labelTotalUpload.text = _numberFormatter.format(NetworkStatsData.getInstance().totalConsumedUpBW); labelTotalUpload.text = NetworkStatsData.getInstance().formattedTotalConsumedUpBW;
labelAvailableUpload.text = _numberFormatter.format(NetworkStatsData.getInstance().measuredUpBW); labelAvailableUpload.text = NetworkStatsData.getInstance().formattedMeasuredUpBW;
labelUploadLatency.text = String(NetworkStatsData.getInstance().measuredUpLatency); labelUploadLatency.text = NetworkStatsData.getInstance().formattedMeasuredUpLatency;
} }
public function getPrefferedPosition():String { public function getPrefferedPosition():String {
@ -82,57 +83,32 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
} }
private function onResize():void { private function onResize():void {
LogUtil.debug("width=" + width + " height=" + height); //LogUtil.debug("width=" + width + " height=" + height);
} }
public function appear():void { private function runBandwidthMeasurement():void {
var fader:Fade = new Fade(); BandwidthMonitor.getInstance().checkClientToServer();
fader.alphaFrom = 0; BandwidthMonitor.getInstance().checkServerToClient();
fader.alphaTo = 1;
fader.duration = 500;
fader.target = this;
// fader.addEventListener(EffectEvent.EFFECT_START, function(e:EffectEvent):void {
// var windowEvent:OpenWindowEvent = new OpenWindowEvent(OpenWindowEvent.OPEN_WINDOW_EVENT);
// windowEvent.window = e.currentTarget as IBbbModuleWindow;
// _globalDispatcher.dispatchEvent(windowEvent);
// });
fader.play();
var windowEvent:OpenWindowEvent = new OpenWindowEvent(OpenWindowEvent.OPEN_WINDOW_EVENT);
windowEvent.window = this;
_globalDispatcher.dispatchEvent(windowEvent);
this.windowManager.bringToFront(this);
} }
public function disappear():void {
var fader:Fade = new Fade();
fader.alphaFrom = 1;
fader.alphaTo = 0;
fader.duration = 500;
fader.target = this;
fader.addEventListener(EffectEvent.EFFECT_END, function(e:EffectEvent):void {
var windowEvent:CloseWindowEvent = new CloseWindowEvent(CloseWindowEvent.CLOSE_WINDOW_EVENT);
windowEvent.window = e.target as IBbbModuleWindow;
_globalDispatcher.dispatchEvent(windowEvent);
});
fader.play();
}
]]> ]]>
</mx:Script> </mx:Script>
<mx:Panel width="100%" height="100%" <mx:Panel id="panel" width="100%"
paddingTop="10" paddingLeft="10" paddingRight="10" paddingBottom="10" headerHeight="10"> paddingTop="10" paddingLeft="10" paddingRight="10" paddingBottom="10" headerHeight="10">
<mx:VBox verticalGap="0" width="100%" height="100%"> <mx:VBox verticalGap="0" width="100%" height="100%">
<mx:HBox backgroundColor="haloOrange" width="100%" horizontalAlign="center"><mx:Label fontWeight="bold" text="Upload"/></mx:HBox> <mx:HBox backgroundColor="haloOrange" width="100%" horizontalAlign="center"><mx:Label fontWeight="bold" text="{ResourceUtil.getInstance().getString('bbb.bwmonitor.upload')}"/></mx:HBox>
<mx:HBox horizontalGap="0"><mx:Label text="Total: "/><mx:Label id="labelTotalUpload" fontWeight="bold" text="-"/><mx:Label text="MB"/></mx:HBox> <mx:HBox visible="false" includeInLayout="false" horizontalGap="0"><mx:Label text="{ResourceUtil.getInstance().getString('bbb.bwmonitor.total')}: "/><mx:Label id="labelTotalUpload" fontWeight="bold" text="-"/></mx:HBox>
<mx:HBox horizontalGap="0"><mx:Label text="Current: "/><mx:Label id="labelCurrentUpload" fontWeight="bold" text="-"/><mx:Label text="Kb/s"/></mx:HBox> <mx:HBox horizontalGap="0"><mx:Label text="{ResourceUtil.getInstance().getString('bbb.bwmonitor.current')}: "/><mx:Label id="labelCurrentUpload" fontWeight="bold" text="-"/></mx:HBox>
<mx:HBox horizontalGap="0"><mx:Label text="Available: "/><mx:Label id="labelAvailableUpload" fontWeight="bold" text="-"/><mx:Label text="Mb/s"/></mx:HBox> <mx:HBox visible="false" includeInLayout="false" horizontalGap="0"><mx:Label text="{ResourceUtil.getInstance().getString('bbb.bwmonitor.available')}: "/><mx:Label id="labelAvailableUpload" fontWeight="bold" text="-"/></mx:HBox>
<mx:HBox horizontalGap="0"><mx:Label text="Latency: "/><mx:Label id="labelUploadLatency" fontWeight="bold" text="-"/><mx:Label text="ms"/></mx:HBox> <mx:HBox horizontalGap="0"><mx:Label text="{ResourceUtil.getInstance().getString('bbb.bwmonitor.latency')}: "/><mx:Label id="labelUploadLatency" fontWeight="bold" text="-"/></mx:HBox>
<mx:HBox backgroundColor="haloOrange" width="100%" horizontalAlign="center"><mx:Label fontWeight="bold" text="Download"/></mx:HBox> <mx:HBox backgroundColor="haloOrange" width="100%" horizontalAlign="center"><mx:Label fontWeight="bold" text="{ResourceUtil.getInstance().getString('bbb.bwmonitor.download')}"/></mx:HBox>
<mx:HBox horizontalGap="0"><mx:Label text="Total: "/><mx:Label id="labelTotalDownload" fontWeight="bold" text="-"/><mx:Label text="MB"/></mx:HBox> <mx:HBox visible="false" includeInLayout="false" horizontalGap="0"><mx:Label text="{ResourceUtil.getInstance().getString('bbb.bwmonitor.total')}: "/><mx:Label id="labelTotalDownload" fontWeight="bold" text="-"/></mx:HBox>
<mx:HBox horizontalGap="0"><mx:Label text="Current: "/><mx:Label id="labelCurrentDownload" fontWeight="bold" text="-"/><mx:Label text="Kb/s"/></mx:HBox> <mx:HBox horizontalGap="0"><mx:Label text="{ResourceUtil.getInstance().getString('bbb.bwmonitor.current')}: "/><mx:Label id="labelCurrentDownload" fontWeight="bold" text="-"/></mx:HBox>
<mx:HBox horizontalGap="0"><mx:Label text="Available: "/><mx:Label id="labelAvailableDownload" fontWeight="bold" text="-"/><mx:Label text="Mb/s"/></mx:HBox> <mx:HBox visible="false" includeInLayout="false" horizontalGap="0"><mx:Label text="{ResourceUtil.getInstance().getString('bbb.bwmonitor.available')}: "/><mx:Label id="labelAvailableDownload" fontWeight="bold" text="-"/></mx:HBox>
<mx:HBox horizontalGap="0"><mx:Label text="Latency: "/><mx:Label id="labelDownloadLatency" fontWeight="bold" text="-"/><mx:Label text="ms"/></mx:HBox> <mx:HBox horizontalGap="0"><mx:Label text="{ResourceUtil.getInstance().getString('bbb.bwmonitor.latency')}: "/><mx:Label id="labelDownloadLatency" fontWeight="bold" text="-"/></mx:HBox>
<mx:HBox horizontalGap="0" width="100%" ><mx:Spacer width="100%"/><mx:Button id="labelRefresh" icon="{_refreshIcon}" width="16" height="16" click="runBandwidthMeasurement()" /></mx:HBox>
</mx:VBox> </mx:VBox>
</mx:Panel> </mx:Panel>

View File

@ -139,5 +139,15 @@ package org.red5.flash.bwcheck
break; break;
} }
} }
public function onBWCheck(obj:Object):void
{
// dispatchStatus(obj);
}
public function onBWDone(obj:Object):void
{
// dispatchComplete(obj);
}
} }
} }