bigbluebutton-Github/bigbluebutton-html5/imports/api/connection-status/server/methods/addConnectionStatus.js

54 lines
1.7 KiB
JavaScript
Raw Normal View History

2020-04-10 01:01:46 +08:00
import { check } from 'meteor/check';
import Logger from '/imports/startup/server/logger';
2020-04-10 01:01:46 +08:00
import updateConnectionStatus from '/imports/api/connection-status/server/modifiers/updateConnectionStatus';
import { extractCredentials } from '/imports/api/common/server/helpers';
const STATS = Meteor.settings.public.stats;
const logConnectionStatus = (meetingId, userId, status, type, value) => {
switch (status) {
case 'normal':
Logger.info(`Connection status updated: meetingId=${meetingId} userId=${userId} status=${status} 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} status=${status} type=${type} jitter=${jitter} loss=${loss}`);
break;
case 'socket':
const { rtt } = value;
Logger.info(`Connection status updated: meetingId=${meetingId} userId=${userId} status=${status} type=${type} rtt=${rtt}`);
break;
default:
}
break;
default:
}
};
export default function addConnectionStatus(status, type, value) {
check(status, String);
check(type, String);
check(value, Object);
2020-04-10 01:01:46 +08:00
const { meetingId, requesterUserId } = extractCredentials(this.userId);
check(meetingId, String);
check(requesterUserId, String);
if (STATS.log) logConnectionStatus(meetingId, requesterUserId, status, type, value);
// Avoid storing recoveries
if (status !== 'normal') {
updateConnectionStatus(meetingId, requesterUserId, status);
}
2020-04-10 01:01:46 +08:00
}