diff --git a/bigbluebutton-html5/imports/api/connection-status/server/methods/addConnectionStatus.js b/bigbluebutton-html5/imports/api/connection-status/server/methods/addConnectionStatus.js index 9e58b49f7f3d0256a8c748bc7d6bf7bc5e9a71e9..8f3763cf80a53cef89c22ef27fd38e9b693d7f77 100644 --- a/bigbluebutton-html5/imports/api/connection-status/server/methods/addConnectionStatus.js +++ b/bigbluebutton-html5/imports/api/connection-status/server/methods/addConnectionStatus.js @@ -1,14 +1,51 @@ import { check } from 'meteor/check'; +import Logger from '/imports/startup/server/logger'; import updateConnectionStatus from '/imports/api/connection-status/server/modifiers/updateConnectionStatus'; import { extractCredentials } from '/imports/api/common/server/helpers'; -export default function addConnectionStatus(level) { - check(level, String); +const logConnectionStatus = (meetingId, userId, status, type, value) => { + switch (status) { + case 'normal': + Logger.info(`Connection status updated: meetingId=${meetingId} userId=${userId} type=${type}`); + break; + case 'warning': + // Skip + break; + case 'danger': + case 'critical': + switch (type) { + case 'audio': + const { + jitter, + loss, + } = value; + Logger.info(`Connection status updated: meetingId=${meetingId} userId=${userId} jitter=${jitter} loss=${loss}`); + break; + case 'socket': + const { rtt } = value; + Logger.info(`Connection status updated: meetingId=${meetingId} userId=${userId} rtt=${rtt}`); + break; + default: + } + break; + default: + } +}; + +export default function addConnectionStatus(status, type, value) { + check(status, String); + check(type, String); + check(value, Object); const { meetingId, requesterUserId } = extractCredentials(this.userId); check(meetingId, String); check(requesterUserId, String); - updateConnectionStatus(meetingId, requesterUserId, level); + logConnectionStatus(meetingId, requesterUserId, status, type, value); + + // Avoid storing recoveries + if (status !== 'normal') { + updateConnectionStatus(meetingId, requesterUserId, status); + } } diff --git a/bigbluebutton-html5/imports/ui/components/connection-status/service.js b/bigbluebutton-html5/imports/ui/components/connection-status/service.js index 4345a61adfb29518b88b727d475260eeff394c7d..7f76175205b9986e483dc7102bcb50496cdc6640 100644 --- a/bigbluebutton-html5/imports/ui/components/connection-status/service.js +++ b/bigbluebutton-html5/imports/ui/components/connection-status/service.js @@ -50,17 +50,17 @@ const getStats = () => { return STATS.level[stats]; }; -const setStats = (level = -1) => { +const setStats = (level = -1, type = 'recovery', value = {}) => { if (stats !== level) { stats = level; statsDep.changed(); - addConnectionStatus(level); + addConnectionStatus(level, type, value); } }; -const handleStats = (level) => { +const handleStats = (level, type, value) => { if (level > stats) { - setStats(level); + setStats(level, type, value); } }; @@ -71,9 +71,9 @@ const handleAudioStatsEvent = (event) => { let active = false; // From higher to lower for (let i = STATS.level.length - 1; i >= 0; i--) { - if (loss > STATS.loss[i] || jitter > STATS.jitter[i]) { + if (loss >= STATS.loss[i] || jitter >= STATS.jitter[i]) { active = true; - handleStats(i); + handleStats(i, 'audio', { loss, jitter }); break; } } @@ -89,9 +89,9 @@ const handleSocketStatsEvent = (event) => { let active = false; // From higher to lower for (let i = STATS.level.length - 1; i >= 0; i--) { - if (rtt > STATS.rtt[i]) { + if (rtt >= STATS.rtt[i]) { active = true; - handleStats(i); + handleStats(i, 'socket', { rtt }); break; } } @@ -108,9 +108,11 @@ const startStatsTimeout = () => { }, STATS.timeout); }; -const addConnectionStatus = (level) => { - if (level !== -1) makeCall('addConnectionStatus', STATS.level[level]); -}; +const addConnectionStatus = (level, type, value) => { + const status = level !== -1 ? STATS.level[level] : 'normal'; + + makeCall('addConnectionStatus', status, type, value); +} const fetchRoundTripTime = () => { const t0 = Date.now(); @@ -323,11 +325,9 @@ const notification = (level, intl) => { }; export default { - addConnectionStatus, getConnectionStatus, getStats, getHelp, - getLevel, isEnabled, notification, startRoundTripTime,