Update transport stats only when advancedMode is on

auto_join_3.3
Roman Drozd 2020-05-20 00:12:33 +02:00
parent 014c805530
commit 3fc8f5683e
2 changed files with 29 additions and 22 deletions

View File

@ -260,9 +260,6 @@ export default class RoomClient
this._startKeyListener(); this._startKeyListener();
this._startDevicesListener(); this._startDevicesListener();
this._getTransportStats();
} }
close() close()
@ -627,29 +624,25 @@ export default class RoomClient
{ {
try try
{ {
setInterval(async () => if (this._recvTransport)
{ {
if (this._recvTransport) logger.debug('getTransportStats() - recv [transportId: "%s"]', this._recvTransport.id);
{
logger.debug('getTransportStats() - recv [transportId: "%s"]', this._recvTransport.id);
const recv = await this.sendRequest('getTransportStats', { transportId: this._recvTransport.id }); const recv = await this.sendRequest('getTransportStats', { transportId: this._recvTransport.id });
store.dispatch( store.dispatch(
transportActions.addTransportStats(recv, 'recv')); transportActions.addTransportStats(recv, 'recv'));
} }
if (this._sendTransport) if (this._sendTransport)
{ {
logger.debug('getTransportStats() - send [transportId: "%s"]', this._sendTransport.id); logger.debug('getTransportStats() - send [transportId: "%s"]', this._sendTransport.id);
const send = await this.sendRequest('getTransportStats', { transportId: this._sendTransport.id }); const send = await this.sendRequest('getTransportStats', { transportId: this._sendTransport.id });
store.dispatch( store.dispatch(
transportActions.addTransportStats(send, 'send')); transportActions.addTransportStats(send, 'send'));
} }
}, 1000);
} }
catch (error) catch (error)
{ {

View File

@ -1,4 +1,4 @@
import React, { useState } from 'react'; import React, { useState, useEffect } from 'react';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { import {
meProducersSelector, meProducersSelector,
@ -334,6 +334,20 @@ const Me = (props) =>
); );
} }
useEffect(() =>
{
let poll;
const interval = 1000;
if (advancedMode)
{
poll = setInterval(() => roomClient._getTransportStats(), interval);
}
return () => clearInterval(poll);
}, [ roomClient, advancedMode ]);
return ( return (
<React.Fragment> <React.Fragment>
<div <div
@ -889,7 +903,7 @@ Me.propTypes =
noiseVolume : PropTypes.number, noiseVolume : PropTypes.number,
classes : PropTypes.object.isRequired, classes : PropTypes.object.isRequired,
theme : PropTypes.object.isRequired, theme : PropTypes.object.isRequired,
transports : PropTypes.object.isRequired transports : PropTypes.object.isRequired
}; };
const makeMapStateToProps = () => const makeMapStateToProps = () =>