Skip to content

Commit 472a6f3

Browse files
author
imdt
committed
Created timeout on RTMP/RTMPT tests.
1 parent 9fa7cf3 commit 472a6f3

File tree

5 files changed

+19
-6
lines changed

5 files changed

+19
-6
lines changed

bigbluebutton-client/src/org/bigbluebutton/main/model/ConfigParameters.as

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ package org.bigbluebutton.main.model
3838
public var suppressLocaleWarning:Boolean = false;
3939
public var portTestHost:String;
4040
public var portTestApplication:String;
41+
public var portTestTimeout:Number;
4142
public var helpURL:String;
4243
public var application:String;
4344
public var host:String;
@@ -71,6 +72,10 @@ package org.bigbluebutton.main.model
7172

7273
portTestHost = xml.porttest.@host;
7374
portTestApplication = xml.porttest.@application;
75+
76+
portTestTimeout = parseInt(xml.porttest.@timeout);
77+
if(isNaN(portTestTimeout) || portTestTimeout < 500) portTestTimeout = 10000;
78+
7479
application = xml.application.@uri;
7580
host = xml.application.@host;
7681
helpURL = xml.help.@url;

bigbluebutton-client/src/org/bigbluebutton/main/model/PortTest.as

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
/*** BigBlueButton open source conferencing system - http://www.bigbluebutton.org/** Copyright (c) 2010 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 2.1 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.main.model{ import flash.events.NetStatusEvent; import flash.net.NetConnection; import flash.net.ObjectEncoding; [Bindable] /** * Test RTMP port. * * @author Thijs Triemstra ( [email protected] ) */ public class PortTest { /** * Protocol name. */ private var protocol : String; /** * Protocol name (uppercase). */ public var protocolName : String; /** * RTMP hostname. */ private var hostname : String; /** * RTMP port. */ public var port : String; /** * RTMP port. */ public var portName : String = "Default"; /** * RTMP application. */ private var application : String; /** * Base RTMP URI. */ private var baseURI : String; /** * RTMP connection. */ public var nc : NetConnection; /** * Connection status. */ public var status : String; private var _connectionListener:Function; /** * Set default encoding to AMF0 so FMS also understands. */ NetConnection.defaultObjectEncoding = ObjectEncoding.AMF0; /** * Create new port test and connect to the RTMP server. * * @param protocol * @param hostname * @param port * @param application */ public function PortTest( protocol : String = "", hostname : String = "", port : String = "", application : String = "" ) { this.protocol = protocol; this.protocolName = protocol.toUpperCase(); this.hostname = hostname; this.application = application; if ( port.length > 0 ) { this.portName = port; this.port = ":" + port; } else { this.port = port; } // Construct URI. this.baseURI = this.protocol + "://" + this.hostname + this.port + "/" + this.application; // } /** * Start connection. */ public function connect() : void { this.nc = new NetConnection(); this.nc.client = this; this.nc.addEventListener( NetStatusEvent.NET_STATUS, netStatus ); // connect to server try { // Create connection with the server. this.nc.connect( this.baseURI ); status = "Connecting..."; } catch( e : ArgumentError ) { // Invalid parameters. status = "ERROR: " + e.message; } } /** * Close connection. */ public function close() : void { // Remove listener. this.nc.removeEventListener( NetStatusEvent.NET_STATUS, netStatus ); // Close the NetConnection. this.nc.close(); } /** * Catch NetStatusEvents. * * @param event */ protected function netStatus( event : NetStatusEvent ) : void { var info : Object = event.info; var statusCode : String = info.code; // if ( statusCode == "NetConnection.Connect.Success" ) { status = "SUCCESS"; _connectionListener(status, protocol, hostname, port, application); } else if ( statusCode == "NetConnection.Connect.Rejected" || statusCode == "NetConnection.Connect.Failed" || statusCode == "NetConnection.Connect.Closed" ) { status = "FAILED"; _connectionListener(status, protocol, hostname, port, application); } // Close NetConnection. close(); } public function onBWCheck(... rest):Number { return 0; } public function onBWDone(... rest):void { var p_bw:Number; if (rest.length > 0) p_bw = rest[0]; // your application should do something here // when the bandwidth check is complete trace("bandwidth = " + p_bw + " Kbps."); } public function addConnectionSuccessListener(listener:Function):void { _connectionListener = listener; } }}
1+
/*** BigBlueButton open source conferencing system - http://www.bigbluebutton.org/** Copyright (c) 2010 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 2.1 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.main.model{ import flash.events.NetStatusEvent; import flash.net.NetConnection; import flash.net.ObjectEncoding; import flash.utils.Timer; import flash.events.TimerEvent; [Bindable] /** * Test RTMP port. * * @author Thijs Triemstra ( [email protected] ) */ public class PortTest { /** * Protocol name. */ private var protocol : String; /** * Protocol name (uppercase). */ public var protocolName : String; /** * RTMP hostname. */ private var hostname : String; /** * RTMP port. */ public var port : String; /** * RTMP port. */ public var portName : String = "Default"; /** * RTMP application. */ private var application : String; /** * Base RTMP URI. */ private var baseURI : String; /** * RTMP connection. */ public var nc : NetConnection; /** * Connection status. */ public var status : String; private var _connectionListener:Function; /** * Timer to control timeout of connection test */ private var testTimeout:Number = 0; /** * Timer to control timeout of connection test */ private var connectionTimer:Timer; /** * Set default encoding to AMF0 so FMS also understands. */ NetConnection.defaultObjectEncoding = ObjectEncoding.AMF0; /** * Create new port test and connect to the RTMP server. * * @param protocol * @param hostname * @param port * @param application * @testTimeout timeout of test in milliseconds */ public function PortTest( protocol : String = "", hostname : String = "", port : String = "", application : String = "", testTimeout : Number = 10000 ) { this.protocol = protocol; this.protocolName = protocol.toUpperCase(); this.hostname = hostname; this.application = application; this.testTimeout = testTimeout; if ( port.length > 0 ) { this.portName = port; this.port = ":" + port; } else { this.port = port; } // Construct URI. this.baseURI = this.protocol + "://" + this.hostname + this.port + "/" + this.application; // } /** * Start connection. */ public function connect() : void { this.nc = new NetConnection(); this.nc.client = this; this.nc.addEventListener( NetStatusEvent.NET_STATUS, netStatus ); // connect to server try { // Create connection with the server. this.nc.connect( this.baseURI ); status = "Connecting..."; connectionTimer = new Timer(testTimeout, 1); connectionTimer.addEventListener(TimerEvent.TIMER, connectionTimeout); connectionTimer.start(); } catch( e : ArgumentError ) { // Invalid parameters. status = "ERROR: " + e.message; } } /** * Method called when connection timed out */ public function connectionTimeout (e:TimerEvent) : void { status = "FAILED"; _connectionListener(status, protocol, hostname, port, application); close(); } /** * Close connection. */ public function close() : void { //Stop timeout timer when connected/rejected connectionTimer.stop(); // Remove listener. this.nc.removeEventListener( NetStatusEvent.NET_STATUS, netStatus ); // Close the NetConnection. this.nc.close(); } /** * Catch NetStatusEvents. * * @param event */ protected function netStatus( event : NetStatusEvent ) : void { var info : Object = event.info; var statusCode : String = info.code; // if ( statusCode == "NetConnection.Connect.Success" ) { status = "SUCCESS"; _connectionListener(status, protocol, hostname, port, application); } else if ( statusCode == "NetConnection.Connect.Rejected" || statusCode == "NetConnection.Connect.Failed" || statusCode == "NetConnection.Connect.Closed" ) { status = "FAILED"; _connectionListener(status, protocol, hostname, port, application); } // Close NetConnection. close(); } public function onBWCheck(... rest):Number { return 0; } public function onBWDone(... rest):void { var p_bw:Number; if (rest.length > 0) p_bw = rest[0]; // your application should do something here // when the bandwidth check is complete trace("bandwidth = " + p_bw + " Kbps."); } public function addConnectionSuccessListener(listener:Function):void { _connectionListener = listener; } }}

bigbluebutton-client/src/org/bigbluebutton/main/model/PortTestProxy.as

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ package org.bigbluebutton.main.model {
3737
modulesDispatcher = new ModulesDispatcher();
3838
}
3939

40-
public function connect(protocol:String = "", hostname:String = "", port:String = "", application:String = ""):void {
41-
var portTest:PortTest = new PortTest(protocol,hostname,port,application);
40+
public function connect(protocol:String = "", hostname:String = "", port:String = "", application:String = "", testTimeout:Number = 10000):void {
41+
var portTest:PortTest = new PortTest(protocol,hostname,port,application, testTimeout);
4242
portTest.addConnectionSuccessListener(connectionListener);
4343
portTest.connect();
4444
}

bigbluebutton-client/src/org/bigbluebutton/main/model/modules/ModuleManager.as

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ package org.bigbluebutton.main.model.modules
8383
return configParameters.portTestApplication;
8484
}
8585

86+
public function get portTestTimeout():Number {
87+
return configParameters.portTestTimeout;
88+
}
89+
8690
private function getModule(name:String):ModuleDescriptor {
8791
return configParameters.getModule(name);
8892
}

bigbluebutton-client/src/org/bigbluebutton/main/model/modules/ModulesProxy.as

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,17 @@ package org.bigbluebutton.main.model.modules
6464
public function getPortTestApplication():String {
6565
return modulesManager.portTestApplication;
6666
}
67+
68+
public function getPortTestTimeout():Number {
69+
return modulesManager.portTestTimeout;
70+
}
6771

6872
public function testRTMP():void{
69-
portTestProxy.connect("RTMP", getPortTestHost(), "1935", getPortTestApplication());
73+
portTestProxy.connect("RTMP", getPortTestHost(), "1935", getPortTestApplication(), getPortTestTimeout());
7074
}
7175

7276
public function testRTMPT(protocol:String):void{
73-
if (protocol == "RTMP") portTestProxy.connect("RTMPT", getPortTestHost(), "", getPortTestApplication());
77+
if (protocol == "RTMP") portTestProxy.connect("RTMPT", getPortTestHost(), "", getPortTestApplication(), getPortTestTimeout());
7478
else modulesDispatcher.sendTunnelingFailedEvent();
7579
}
7680

@@ -86,4 +90,4 @@ package org.bigbluebutton.main.model.modules
8690
modulesManager.startAllModules();
8791
}
8892
}
89-
}
93+
}

0 commit comments

Comments
 (0)