Merge branch 'webrtc-reconnect' into v0.9.0-release
Conflicts: bigbluebutton-client/resources/prod/lib/bbb_webrtc_bridge_sip.js bigbluebutton-client/src/org/bigbluebutton/modules/phone/managers/WebRTCCallManager.as
This commit is contained in:
commit
ddfbd0b138
@ -78,6 +78,9 @@ bbb.webrtcWarning.failedError.1009 = Error 1009: Could not fetch STUN/TURN serve
|
||||
bbb.webrtcWarning.failedError.unknown = Error {0}: Unknown error code
|
||||
bbb.webrtcWarning.failedError.mediamissing = Could not get your microphone for a WebRTC call
|
||||
bbb.webrtcWarning.failedError.endedunexpectedly = The WebRTC echo test ended unexpectedly
|
||||
bbb.webrtcWarning.connection.dropped = WebRTC connection dropped
|
||||
bbb.webrtcWarning.connection.reconnecting = Attempting to reconnect
|
||||
bbb.webrtcWarning.connection.reestablished = WebRTC connection re-established
|
||||
bbb.mainToolbar.helpBtn = Help
|
||||
bbb.mainToolbar.logoutBtn = Logout
|
||||
bbb.mainToolbar.logoutBtn.toolTip = Log Out
|
||||
|
@ -78,6 +78,9 @@ bbb.webrtcWarning.failedError.1009 = Erro 1009\: Não foi possível recuperar as
|
||||
bbb.webrtcWarning.failedError.unknown = Erro {0}\: Código de erro desconhecido
|
||||
bbb.webrtcWarning.failedError.mediamissing = Não foi possível acessar seu microfone para a chamada WebRTC
|
||||
bbb.webrtcWarning.failedError.endedunexpectedly = O teste de eco WebRTC terminou inesperadamente
|
||||
bbb.webrtcWarning.connection.dropped = Falha na conexão WebRTC
|
||||
bbb.webrtcWarning.connection.reconnecting = Tentando reconexão
|
||||
bbb.webrtcWarning.connection.reestablished = Conexão WebRTC re-estabelecida
|
||||
bbb.mainToolbar.helpBtn = Ajuda
|
||||
bbb.mainToolbar.logoutBtn = Sair
|
||||
bbb.mainToolbar.logoutBtn.toolTip = Sair da sessão
|
||||
|
@ -68,6 +68,10 @@ function callIntoConference(voiceBridge, callback) {
|
||||
function joinWebRTCVoiceConference() {
|
||||
console.log("Joining to the voice conference directly");
|
||||
inEchoTest = false;
|
||||
// set proper callbacks to previously created user agent
|
||||
if(userAgent) {
|
||||
setUserAgentListeners(webRTCCallback);
|
||||
}
|
||||
callIntoConference(conferenceVoiceBridge, webRTCCallback);
|
||||
}
|
||||
|
||||
@ -172,10 +176,18 @@ function createUAWithStuns(username, server, callback, stunsConfig, makeCallFunc
|
||||
uaConnected = false;
|
||||
|
||||
userAgent = new SIP.UA(configuration);
|
||||
setUserAgentListeners(callback, makeCallFunc);
|
||||
userAgent.start();
|
||||
};
|
||||
|
||||
function setUserAgentListeners(callback, makeCallFunc) {
|
||||
console.log("reseting UA callbacks");
|
||||
userAgent.off('connected');
|
||||
userAgent.on('connected', function() {
|
||||
uaConnected = true;
|
||||
makeCallFunc();
|
||||
});
|
||||
userAgent.off('disconnected');
|
||||
userAgent.on('disconnected', function() {
|
||||
if (userAgent) {
|
||||
if (userAgent != null) {
|
||||
@ -191,8 +203,6 @@ function createUAWithStuns(username, server, callback, stunsConfig, makeCallFunc
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
userAgent.start();
|
||||
};
|
||||
|
||||
function getUserMicMedia(getUserMicMediaSuccess, getUserMicMediaFailure) {
|
||||
|
@ -0,0 +1,68 @@
|
||||
/**
|
||||
* BigBlueButton open source conferencing system - http://www.bigbluebutton.org/
|
||||
*
|
||||
* Copyright (c) 2015 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.main.model.users
|
||||
{
|
||||
import flash.events.TimerEvent;
|
||||
import flash.utils.Timer;
|
||||
|
||||
public class AutoReconnect
|
||||
{
|
||||
public static const LOG:String = "AutoReconnect - ";
|
||||
|
||||
private var _backoff:Number;
|
||||
private var _initialBackoff:Number;
|
||||
private var _reconnectCallback:Function;
|
||||
private var _reconnectParameters:Array;
|
||||
private var _retries: Number;
|
||||
|
||||
public function AutoReconnect(initialBackoff:Number = 1000) {
|
||||
_initialBackoff = initialBackoff;
|
||||
_backoff = initialBackoff;
|
||||
}
|
||||
|
||||
public function onDisconnect(callback:Function, ...parameters):void {
|
||||
trace(LOG + "onDisconnect, parameters=" + parameters.toString());
|
||||
_reconnectCallback = callback;
|
||||
_reconnectParameters = parameters;
|
||||
attemptReconnect(_initialBackoff);
|
||||
_retries = 1;
|
||||
}
|
||||
|
||||
public function onConnectionAttemptFailed():void {
|
||||
trace(LOG + "onConnectionAttemptFailed");
|
||||
attemptReconnect(_backoff);
|
||||
_retries = _retries + 1;
|
||||
}
|
||||
|
||||
private function attemptReconnect(backoff:Number):void {
|
||||
trace(LOG + "attemptReconnect backoff=" + backoff);
|
||||
var retryTimer:Timer = new Timer(backoff, 1);
|
||||
retryTimer.addEventListener(TimerEvent.TIMER, function():void {
|
||||
trace(LOG + "Reconnecting");
|
||||
_reconnectCallback.apply(null, _reconnectParameters);
|
||||
});
|
||||
retryTimer.start();
|
||||
if (_backoff < 16000) _backoff = backoff *2;
|
||||
}
|
||||
|
||||
public function get Retries():Number {
|
||||
return _retries;
|
||||
}
|
||||
}
|
||||
}
|
@ -14,6 +14,7 @@ package org.bigbluebutton.modules.phone.managers
|
||||
import org.bigbluebutton.core.UsersUtil;
|
||||
import org.bigbluebutton.main.api.JSAPI;
|
||||
import org.bigbluebutton.main.events.ClientStatusEvent;
|
||||
import org.bigbluebutton.main.model.users.AutoReconnect;
|
||||
import org.bigbluebutton.modules.phone.PhoneModel;
|
||||
import org.bigbluebutton.modules.phone.PhoneOptions;
|
||||
import org.bigbluebutton.modules.phone.events.AudioSelectionWindowEvent;
|
||||
@ -44,6 +45,11 @@ package org.bigbluebutton.modules.phone.managers
|
||||
private var options:PhoneOptions;
|
||||
|
||||
private var model:WebRTCModel = PhoneModel.getInstance().webRTCModel;
|
||||
|
||||
private var INITIAL_BACKOFF:Number = 100;
|
||||
private var MAX_RETRIES:Number = 3;
|
||||
private var reconnect:AutoReconnect = new AutoReconnect(INITIAL_BACKOFF);
|
||||
private var reconnecting:Boolean = false;
|
||||
|
||||
public function WebRTCCallManager() {
|
||||
var browserInfo:Array = JSAPI.getInstance().getBrowserInfo();
|
||||
@ -59,8 +65,6 @@ package org.bigbluebutton.modules.phone.managers
|
||||
ResourceUtil.getInstance().getString("bbb.clientstatus.webrtc.title"),
|
||||
ResourceUtil.getInstance().getString("bbb.clientstatus.webrtc.message")));
|
||||
}
|
||||
|
||||
usingWebRTC = checkIfToUseWebRTC();
|
||||
}
|
||||
|
||||
private function isWebRTCSupported():Boolean {
|
||||
@ -131,7 +135,12 @@ package org.bigbluebutton.modules.phone.managers
|
||||
trace(LOG + "setting state to IN_CONFERENCE");
|
||||
model.state = Constants.IN_CONFERENCE;
|
||||
dispatcher.dispatchEvent(new WebRTCJoinedVoiceConferenceEvent());
|
||||
|
||||
if(reconnecting) {
|
||||
dispatcher.dispatchEvent(new ClientStatusEvent(ClientStatusEvent.SUCCESS_MESSAGE_EVENT,
|
||||
ResourceUtil.getInstance().getString("bbb.webrtcWarning.connection.reestablished"),
|
||||
ResourceUtil.getInstance().getString("bbb.webrtcWarning.connection.reestablished")));
|
||||
reconnecting = false;
|
||||
}
|
||||
}
|
||||
|
||||
public function handleWebRTCCallEndedEvent():void {
|
||||
@ -148,6 +157,8 @@ package org.bigbluebutton.modules.phone.managers
|
||||
public function handleJoinVoiceConferenceCommand(event:JoinVoiceConferenceCommand):void {
|
||||
trace(LOG + "handleJoinVoiceConferenceCommand - usingWebRTC: " + usingWebRTC + ", event.mic: " + event.mic);
|
||||
|
||||
usingWebRTC = checkIfToUseWebRTC();
|
||||
|
||||
if (!usingWebRTC || !event.mic) return;
|
||||
|
||||
if (options.skipCheck || echoTestDone) {
|
||||
@ -206,19 +217,42 @@ package org.bigbluebutton.modules.phone.managers
|
||||
}
|
||||
|
||||
public function handleWebRTCCallFailedEvent(event:WebRTCCallEvent):void {
|
||||
var errorString:String;
|
||||
trace(LOG + "handleWebRTCCallFailedEvent");
|
||||
model.state = Constants.INITED;
|
||||
|
||||
if (event.errorCode == 1004) {
|
||||
errorString = ResourceUtil.getInstance().getString("bbb.webrtcWarning.failedError." + event.errorCode, [event.cause]);
|
||||
} else {
|
||||
errorString = ResourceUtil.getInstance().getString("bbb.webrtcWarning.failedError." + event.errorCode);
|
||||
if(!reconnecting) {
|
||||
trace(LOG + "WebRTC call failed, attempting reconnection");
|
||||
reconnecting = true;
|
||||
dispatcher.dispatchEvent(new ClientStatusEvent(ClientStatusEvent.WARNING_MESSAGE_EVENT,
|
||||
ResourceUtil.getInstance().getString("bbb.webrtcWarning.connection.dropped"),
|
||||
ResourceUtil.getInstance().getString("bbb.webrtcWarning.connection.reconnecting")));
|
||||
reconnect.onDisconnect(joinVoiceConference);
|
||||
}
|
||||
|
||||
if (!errorString) {
|
||||
errorString = ResourceUtil.getInstance().getString("bbb.webrtcWarning.failedError.unknown", [event.errorCode]);
|
||||
else {
|
||||
trace(LOG + "WebRTC call reconnection failed");
|
||||
if( reconnect.Retries < MAX_RETRIES ) {
|
||||
trace(LOG + "Retring... " + reconnect.Retries);
|
||||
reconnect.onConnectionAttemptFailed();
|
||||
}
|
||||
else {
|
||||
trace(LOG + "Giving up");
|
||||
reconnecting = false;
|
||||
dispatcher.dispatchEvent(new WebRTCCallEvent(WebRTCCallEvent.WEBRTC_CALL_ENDED));
|
||||
|
||||
var errorString:String;
|
||||
|
||||
if (event.errorCode == 1004) {
|
||||
errorString = ResourceUtil.getInstance().getString("bbb.webrtcWarning.failedError." + event.errorCode, [event.cause]);
|
||||
} else {
|
||||
errorString = ResourceUtil.getInstance().getString("bbb.webrtcWarning.failedError." + event.errorCode);
|
||||
}
|
||||
|
||||
if (!errorString) {
|
||||
errorString = ResourceUtil.getInstance().getString("bbb.webrtcWarning.failedError.unknown", [event.errorCode]);
|
||||
}
|
||||
sendWebRTCAlert(ResourceUtil.getInstance().getString("bbb.webrtcWarning.title"), ResourceUtil.getInstance().getString("bbb.webrtcWarning.message", [errorString]), errorString);
|
||||
}
|
||||
}
|
||||
sendWebRTCAlert(ResourceUtil.getInstance().getString("bbb.webrtcWarning.title"), ResourceUtil.getInstance().getString("bbb.webrtcWarning.message", [errorString]), errorString);
|
||||
}
|
||||
|
||||
public function handleWebRTCMediaFailedEvent():void {
|
||||
|
Loading…
Reference in New Issue
Block a user