068b82b1fa
Remove parts of a previous connection monitor.
To add some context (as far as my memory goes) to the multiple connection
monitor features the product has, `stats` (currently named `connection status`)
was introduced at the Flash client back in ~2016. @fcecagno and I did it
as a BigBlueButton's Summit activity. Our work was squashed into a single
commit in 92554f8b3e
:).
I'm not sure about the whole story behind `network information` (the late
connection monitor added to the HTML5 client) but I assume it should work
as a collector for a bunch of different connectivity monitors. I remember
when it was introduced but I don't know why it wasn't adopted. My best guess
would be because of some performance issues the `user list` had back then.
To follow on why `connection status` replaced `network information` at the
HTML5 client, when I did the `multiple webcams` feature I had to refactor
a big chunk of the `video provider` (#8374). Something that wasn't really
helping there was the adaptation of `stats` that was made to show local
feedback for each webcam connection. Although this feature wasn't being
used anymore, `network information` did rely on that to build up data. With
this monitor gone I assumed it was my responsibility to provide an alternative
so I promoted Mconf's port of the Flash `stats` monitor to BigBlueButton's
HTML5 client (#8579).
Well, that's my perspective on how things went for those features. If
anyone would like to correct me on something or add something else on
that history I would appreciate to know.
206 lines
6.4 KiB
JavaScript
206 lines
6.4 KiB
JavaScript
import { Meteor } from 'meteor/meteor';
|
|
import { withTracker } from 'meteor/react-meteor-data';
|
|
import React, { Fragment } from 'react';
|
|
import { defineMessages, injectIntl } from 'react-intl';
|
|
import _ from 'lodash';
|
|
import Auth from '/imports/ui/services/auth';
|
|
import Meetings, { MeetingTimeRemaining } from '/imports/api/meetings';
|
|
import BreakoutRemainingTime from '/imports/ui/components/breakout-room/breakout-remaining-time/container';
|
|
import { styles } from './styles.scss';
|
|
|
|
import breakoutService from '/imports/ui/components/breakout-room/service';
|
|
import NotificationsBar from './component';
|
|
|
|
// disconnected and trying to open a new connection
|
|
const STATUS_CONNECTING = 'connecting';
|
|
|
|
// permanently failed to connect; e.g., the client and server support different versions of DDP
|
|
const STATUS_FAILED = 'failed';
|
|
|
|
// failed to connect and waiting to try to reconnect
|
|
const STATUS_WAITING = 'waiting';
|
|
|
|
const METEOR_SETTINGS_APP = Meteor.settings.public.app;
|
|
|
|
const REMAINING_TIME_THRESHOLD = METEOR_SETTINGS_APP.remainingTimeThreshold;
|
|
const REMAINING_TIME_ALERT_THRESHOLD = METEOR_SETTINGS_APP.remainingTimeAlertThreshold;
|
|
|
|
const intlMessages = defineMessages({
|
|
failedMessage: {
|
|
id: 'app.failedMessage',
|
|
description: 'Notification for connecting to server problems',
|
|
},
|
|
connectingMessage: {
|
|
id: 'app.connectingMessage',
|
|
description: 'Notification message for when client is connecting to server',
|
|
},
|
|
waitingMessage: {
|
|
id: 'app.waitingMessage',
|
|
description: 'Notification message for disconnection with reconnection counter',
|
|
},
|
|
retryNow: {
|
|
id: 'app.retryNow',
|
|
description: 'Retry now text for reconnection counter',
|
|
},
|
|
breakoutTimeRemaining: {
|
|
id: 'app.breakoutTimeRemainingMessage',
|
|
description: 'Message that tells how much time is remaining for the breakout room',
|
|
},
|
|
breakoutWillClose: {
|
|
id: 'app.breakoutWillCloseMessage',
|
|
description: 'Message that tells time has ended and breakout will close',
|
|
},
|
|
calculatingBreakoutTimeRemaining: {
|
|
id: 'app.calculatingBreakoutTimeRemaining',
|
|
description: 'Message that tells that the remaining time is being calculated',
|
|
},
|
|
meetingTimeRemaining: {
|
|
id: 'app.meeting.meetingTimeRemaining',
|
|
description: 'Message that tells how much time is remaining for the meeting',
|
|
},
|
|
meetingWillClose: {
|
|
id: 'app.meeting.meetingTimeHasEnded',
|
|
description: 'Message that tells time has ended and meeting will close',
|
|
},
|
|
alertMeetingEndsUnderMinutes: {
|
|
id: 'app.meeting.alertMeetingEndsUnderMinutes',
|
|
description: 'Alert that tells that the meeting ends under x minutes',
|
|
},
|
|
alertBreakoutEndsUnderMinutes: {
|
|
id: 'app.meeting.alertBreakoutEndsUnderMinutes',
|
|
description: 'Alert that tells that the breakout ends under x minutes',
|
|
},
|
|
});
|
|
|
|
const NotificationsBarContainer = (props) => {
|
|
const { message, color } = props;
|
|
if (_.isEmpty(message)) {
|
|
return null;
|
|
}
|
|
|
|
|
|
return (
|
|
<NotificationsBar color={color}>
|
|
{message}
|
|
</NotificationsBar>
|
|
);
|
|
};
|
|
|
|
let retrySeconds = 0;
|
|
const retrySecondsDep = new Tracker.Dependency();
|
|
let retryInterval = null;
|
|
|
|
const getRetrySeconds = () => {
|
|
retrySecondsDep.depend();
|
|
return retrySeconds;
|
|
};
|
|
|
|
const setRetrySeconds = (sec = 0) => {
|
|
if (sec !== retrySeconds) {
|
|
retrySeconds = sec;
|
|
retrySecondsDep.changed();
|
|
}
|
|
};
|
|
|
|
const startCounter = (sec, set, get, interval) => {
|
|
clearInterval(interval);
|
|
set(sec);
|
|
return setInterval(() => {
|
|
set(get() - 1);
|
|
}, 1000);
|
|
};
|
|
|
|
const reconnect = () => {
|
|
Meteor.reconnect();
|
|
};
|
|
|
|
export default injectIntl(withTracker(({ intl }) => {
|
|
const { status, connected, retryTime } = Meteor.status();
|
|
const data = {};
|
|
|
|
if (!connected) {
|
|
data.color = 'primary';
|
|
switch (status) {
|
|
case STATUS_FAILED: {
|
|
data.color = 'danger';
|
|
data.message = intl.formatMessage(intlMessages.failedMessage);
|
|
break;
|
|
}
|
|
case STATUS_CONNECTING: {
|
|
data.message = intl.formatMessage(intlMessages.connectingMessage);
|
|
break;
|
|
}
|
|
case STATUS_WAITING: {
|
|
const sec = Math.round((retryTime - (new Date()).getTime()) / 1000);
|
|
retryInterval = startCounter(sec, setRetrySeconds, getRetrySeconds, retryInterval);
|
|
data.message = (
|
|
<Fragment>
|
|
{intl.formatMessage(intlMessages.waitingMessage, { 0: getRetrySeconds() })}
|
|
<button className={styles.retryButton} type="button" onClick={reconnect}>
|
|
{intl.formatMessage(intlMessages.retryNow)}
|
|
</button>
|
|
</Fragment>
|
|
);
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
|
|
return data;
|
|
}
|
|
|
|
const meetingId = Auth.meetingID;
|
|
const breakouts = breakoutService.getBreakouts();
|
|
|
|
const msg = { id: `${intlMessages.alertBreakoutEndsUnderMinutes.id}${REMAINING_TIME_ALERT_THRESHOLD == 1 ? 'Singular' : 'Plural'}` };
|
|
|
|
if (breakouts.length > 0) {
|
|
const currentBreakout = breakouts.find(b => b.breakoutId === meetingId);
|
|
|
|
if (currentBreakout) {
|
|
data.message = (
|
|
<BreakoutRemainingTime
|
|
breakoutRoom={currentBreakout}
|
|
messageDuration={intlMessages.breakoutTimeRemaining}
|
|
timeEndedMessage={intlMessages.breakoutWillClose}
|
|
alertMessage={
|
|
intl.formatMessage(msg, {0: REMAINING_TIME_ALERT_THRESHOLD})
|
|
}
|
|
alertUnderMinutes={REMAINING_TIME_ALERT_THRESHOLD}
|
|
/>
|
|
);
|
|
}
|
|
}
|
|
|
|
const meetingTimeRemaining = MeetingTimeRemaining.findOne({ meetingId });
|
|
const Meeting = Meetings.findOne({ meetingId },
|
|
{ fields: { 'meetingProp.isBreakout': 1 } });
|
|
|
|
if (meetingTimeRemaining && Meeting) {
|
|
const { timeRemaining } = meetingTimeRemaining;
|
|
const { isBreakout } = Meeting.meetingProp;
|
|
const underThirtyMin = timeRemaining && timeRemaining <= (REMAINING_TIME_THRESHOLD * 60);
|
|
|
|
const msg = { id: `${intlMessages.alertMeetingEndsUnderMinutes.id}${REMAINING_TIME_ALERT_THRESHOLD == 1 ? 'Singular' : 'Plural'}` };
|
|
|
|
if (underThirtyMin && !isBreakout) {
|
|
data.message = (
|
|
<BreakoutRemainingTime
|
|
breakoutRoom={meetingTimeRemaining}
|
|
messageDuration={intlMessages.meetingTimeRemaining}
|
|
timeEndedMessage={intlMessages.meetingWillClose}
|
|
alertMessage={
|
|
intl.formatMessage(msg, {0: REMAINING_TIME_ALERT_THRESHOLD})
|
|
}
|
|
alertUnderMinutes={REMAINING_TIME_ALERT_THRESHOLD}
|
|
/>
|
|
);
|
|
}
|
|
}
|
|
|
|
data.alert = true;
|
|
data.color = 'primary';
|
|
return data;
|
|
})(NotificationsBarContainer));
|