diff --git a/conference.js b/conference.js index 4386e0878..1dfa27a85 100644 --- a/conference.js +++ b/conference.js @@ -25,6 +25,11 @@ const TrackErrors = JitsiMeetJS.errors.track; let room, connection, localAudio, localVideo, roomLocker; +/** + * Indicates whether the connection is interrupted or not. + */ +let connectionIsInterrupted = false; + import {VIDEO_CONTAINER_TYPE} from "./modules/UI/videolayout/LargeVideo"; /** @@ -1076,6 +1081,15 @@ export default { }); } + room.on(ConferenceEvents.CONNECTION_INTERRUPTED, () => { + connectionIsInterrupted = true; + ConnectionQuality.updateLocalConnectionQuality(0); + }); + + room.on(ConferenceEvents.CONNECTION_RESTORED, () => { + connectionIsInterrupted = false; + }); + room.on(ConferenceEvents.DISPLAY_NAME_CHANGED, (id, displayName) => { APP.API.notifyDisplayNameChanged(id, displayName); APP.UI.changeDisplayName(id, displayName); @@ -1131,7 +1145,7 @@ export default { } room.on(ConferenceEvents.CONNECTION_STATS, function (stats) { - ConnectionQuality.updateLocalStats(stats); + ConnectionQuality.updateLocalStats(stats, connectionIsInterrupted); }); ConnectionQuality.addListener(CQEvents.LOCALSTATS_UPDATED, diff --git a/modules/connectionquality/connectionquality.js b/modules/connectionquality/connectionquality.js index 7bcceca2c..3b24417e9 100644 --- a/modules/connectionquality/connectionquality.js +++ b/modules/connectionquality/connectionquality.js @@ -41,12 +41,26 @@ export default { /** * Updates the local statistics * @param data new statistics + * @param dontUpdateLocalConnectionQuality {boolean} if true - + * localConnectionQuality wont be recalculated. */ - updateLocalStats: function (data) { + updateLocalStats: function (data, dontUpdateLocalConnectionQuality) { stats = data; - var newVal = 100 - stats.packetLoss.total; - localConnectionQuality = - calculateQuality(newVal, localConnectionQuality); + if(!dontUpdateLocalConnectionQuality) { + var newVal = 100 - stats.packetLoss.total; + localConnectionQuality = + calculateQuality(newVal, localConnectionQuality); + } + eventEmitter.emit(CQEvents.LOCALSTATS_UPDATED, localConnectionQuality, + stats); + }, + + /** + * Updates only the localConnectionQuality value + * @param values {int} the new value. should be from 0 - 100. + */ + updateLocalConnectionQuality: function (value) { + localConnectionQuality = value; eventEmitter.emit(CQEvents.LOCALSTATS_UPDATED, localConnectionQuality, stats); },