update logic and rename function

This commit is contained in:
Joao Siebel 2019-04-22 09:11:16 -03:00
parent 08d177dac0
commit 067801acae
2 changed files with 12 additions and 11 deletions

View File

@ -8,7 +8,7 @@ import logger from '/imports/startup/client/logger';
import { Session } from 'meteor/session'; import { Session } from 'meteor/session';
import browser from 'browser-detect'; import browser from 'browser-detect';
import { import {
currentWebcamConnections, updateCurrentWebcamsConnection,
getCurrentWebcams, getCurrentWebcams,
deleteWebcamConnection, deleteWebcamConnection,
newWebcamConnection, newWebcamConnection,
@ -478,7 +478,7 @@ class VideoProvider extends Component {
} }
delete this.webRtcPeers[id]; delete this.webRtcPeers[id];
deleteWebcamConnection(id); deleteWebcamConnection(id);
currentWebcamConnections(this.webRtcPeers); updateCurrentWebcamsConnection(this.webRtcPeers);
} else { } else {
this.logger('warn', 'No WebRTC peer to stop (not an error)', { cameraId: id }); this.logger('warn', 'No WebRTC peer to stop (not an error)', { cameraId: id });
} }
@ -561,7 +561,7 @@ class VideoProvider extends Component {
this.webRtcPeers[id].peerConnection.oniceconnectionstatechange = this._getOnIceConnectionStateChangeCallback(id); this.webRtcPeers[id].peerConnection.oniceconnectionstatechange = this._getOnIceConnectionStateChangeCallback(id);
} }
newWebcamConnection({ userId: id, peer: this.webRtcPeers[id] }); newWebcamConnection({ userId: id, peer: this.webRtcPeers[id] });
currentWebcamConnections(this.webRtcPeers); updateCurrentWebcamsConnection(this.webRtcPeers);
} }
} }

View File

@ -17,11 +17,11 @@ const WARNING_END_TIME = 60000;
let monitoringIntervalRef; let monitoringIntervalRef;
export const currentWebcamConnections = (webrtcConnections) => { export const updateCurrentWebcamsConnection = (connections) => {
const doc = { const doc = {
timestamp: new Date().getTime(), timestamp: new Date().getTime(),
event: NUMBER_OF_WEBCAMS_CHANGED, event: NUMBER_OF_WEBCAMS_CHANGED,
payload: Object.keys(webrtcConnections), payload: Object.keys(connections),
}; };
NetworkInformationLocal.insert(doc); NetworkInformationLocal.insert(doc);
@ -110,14 +110,15 @@ export const startBandwidthMonitoring = () => {
time: { $lt: dangerLowerBoundary, $gte: warningLowerBoundary }, time: { $lt: dangerLowerBoundary, $gte: warningLowerBoundary },
}).count(); }).count();
if (warningZoneReceivers && !dangerZone) {
if (!warningZoneReceivers) { if (dangerZone) {
makeCall('setUserEffectiveConnectionType', 'warning');
}
} else if (dangerZone) {
if (!dangerZoneReceivers) { if (!dangerZoneReceivers) {
makeCall('setUserEffectiveConnectionType', 'danger'); makeCall('setUserEffectiveConnectionType', 'danger');
} }
} else if (warningZone) {
if (!warningZoneReceivers) {
makeCall('setUserEffectiveConnectionType', 'warning');
}
} else { } else {
makeCall('setUserEffectiveConnectionType', ''); makeCall('setUserEffectiveConnectionType', '');
} }
@ -192,7 +193,7 @@ export const updateWebcamStats = (id, stats) => {
export default { export default {
NetworkInformationLocal, NetworkInformationLocal,
currentWebcamConnections, updateCurrentWebcamsConnection,
deleteWebcamConnection, deleteWebcamConnection,
getCurrentWebcams, getCurrentWebcams,
newWebcamConnection, newWebcamConnection,