- bw mon determine connection type

This commit is contained in:
Richard Alam 2018-01-19 08:38:55 -08:00
parent a3f3760d49
commit e388173f1f
2 changed files with 72 additions and 20 deletions

View File

@ -25,7 +25,11 @@ package org.bigbluebutton.core.services
import org.as3commons.logging.api.ILogger;
import org.as3commons.logging.api.getClassLogger;
import org.bigbluebutton.core.BBB;
import org.bigbluebutton.core.Options;
import org.bigbluebutton.core.model.BandwidthMonOptions;
import org.bigbluebutton.main.model.NetworkStatsData;
import org.bigbluebutton.util.ConnUtil;
import org.red5.flash.bwcheck.ClientServerBandwidth;
import org.red5.flash.bwcheck.ServerClientBandwidth;
import org.red5.flash.bwcheck.events.BandwidthDetectEvent;
@ -35,8 +39,6 @@ package org.bigbluebutton.core.services
public static const INTERVAL_BETWEEN_CHECKS:int = 30000; // in ms
private static var _instance:BandwidthMonitor = null;
private var _serverURL:String = "localhost";
private var _serverApplication:String = "video";
private var _clientServerService:String = "checkBandwidthUp";
private var _serverClientService:String = "checkBandwidth";
private var _pendingClientToServer:Boolean;
@ -83,26 +85,43 @@ package org.bigbluebutton.core.services
}
return _instance;
}
public function set serverURL(url:String):void {
if (_nc.connected)
_nc.close();
_serverURL = url;
}
public function set serverApplication(app:String):void {
if (_nc.connected)
_nc.close();
_serverApplication = app;
}
public function start():void {
connect();
}
private function connect():void {
if (!_nc.connected && !_connecting) {
_nc.connect("rtmp://" + _serverURL + "/" + _serverApplication);
var bwMonOption:BandwidthMonOptions = Options.getOptions(BandwidthMonOptions) as BandwidthMonOptions;
var pattern:RegExp = /(?P<protocol>.+):\/\/(?P<server>.+)/;
var result:Array = pattern.exec(bwMonOption.server);
var bwMonUrl: String;
var useRTMPS: Boolean = result.protocol == ConnUtil.RTMPS;
if (BBB.initConnectionManager().isTunnelling) {
var tunnelProtocol: String = ConnUtil.RTMPT;
if (useRTMPS) {
_nc.proxyType = ConnUtil.PROXY_NONE;
tunnelProtocol = ConnUtil.RTMPS;
}
bwMonUrl = tunnelProtocol + "://" + result.server + "/" + bwMonOption.application;
trace("******* BW MON CONNECT tunnel = TRUE " + "url=" + bwMonUrl);
} else {
var nativeProtocol: String = ConnUtil.RTMP;
if (useRTMPS) {
_nc.proxyType = ConnUtil.PROXY_BEST;
nativeProtocol = ConnUtil.RTMPS;
}
bwMonUrl = nativeProtocol + "://" + result.server + "/" + bwMonOption.application;
trace("******* BBB MON CONNECT tunnel = FALSE " + "url=" + bwMonUrl);
}
_nc.connect(bwMonUrl);
_connecting = true;
}
}

View File

@ -7,6 +7,10 @@ package org.red5.flash.bwcheck.app
import mx.core.Application;
import org.bigbluebutton.common.LogUtil;
import org.bigbluebutton.core.BBB;
import org.bigbluebutton.core.Options;
import org.bigbluebutton.core.model.BandwidthMonOptions;
import org.bigbluebutton.util.ConnUtil;
import org.red5.flash.bwcheck.ClientServerBandwidth;
import org.red5.flash.bwcheck.ServerClientBandwidth;
import org.red5.flash.bwcheck.events.BandwidthDetectEvent;
@ -17,7 +21,7 @@ package org.red5.flash.bwcheck.app
private var _serverApplication:String = "";
private var _clientServerService:String = "";
private var _serverClientService:String = "";
private var bwMonOption: BandwidthMonOptions;
private var nc:NetConnection;
public function BandwidthDetectionApp()
@ -47,12 +51,41 @@ package org.red5.flash.bwcheck.app
public function connect():void
{
bwMonOption = Options.getOptions(BandwidthMonOptions) as BandwidthMonOptions;
var pattern:RegExp = /(?P<protocol>.+):\/\/(?P<server>.+)/;
var result:Array = pattern.exec(bwMonOption.server);
var bwMonUrl: String;
nc = new NetConnection();
nc.proxyType = "best";
nc.objectEncoding = flash.net.ObjectEncoding.AMF0;
var useRTMPS: Boolean = result.protocol == ConnUtil.RTMPS;
if (BBB.initConnectionManager().isTunnelling) {
var tunnelProtocol: String = ConnUtil.RTMPT;
if (useRTMPS) {
nc.proxyType = ConnUtil.PROXY_NONE;
tunnelProtocol = ConnUtil.RTMPS;
}
bwMonUrl = tunnelProtocol + "://" + result.server + "/" + bwMonOption.application;
trace("******* BW MON CONNECT tunnel = TRUE " + "url=" + bwMonUrl);
} else {
var nativeProtocol: String = ConnUtil.RTMP;
if (useRTMPS) {
nc.proxyType = ConnUtil.PROXY_BEST;
nativeProtocol = ConnUtil.RTMPS;
}
bwMonUrl = nativeProtocol + "://" + result.server + "/" + bwMonOption.application;
trace("******* BBB MON CONNECT tunnel = FALSE " + "url=" + bwMonUrl);
}
nc.objectEncoding = flash.net.ObjectEncoding.AMF3;
nc.client = this;
nc.addEventListener(NetStatusEvent.NET_STATUS, onStatus);
nc.connect("rtmp://" + _serverURL + "/" + _serverApplication);
nc.connect(bwMonUrl);
}