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._startDevicesListener();
this._getTransportStats();
}
close()
@ -627,29 +624,25 @@ export default class RoomClient
{
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(
transportActions.addTransportStats(recv, 'recv'));
}
store.dispatch(
transportActions.addTransportStats(recv, 'recv'));
}
if (this._sendTransport)
{
logger.debug('getTransportStats() - send [transportId: "%s"]', this._sendTransport.id);
if (this._sendTransport)
{
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(
transportActions.addTransportStats(send, 'send'));
}
}, 1000);
store.dispatch(
transportActions.addTransportStats(send, 'send'));
}
}
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 {
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 (
<React.Fragment>
<div
@ -889,7 +903,7 @@ Me.propTypes =
noiseVolume : PropTypes.number,
classes : PropTypes.object.isRequired,
theme : PropTypes.object.isRequired,
transports : PropTypes.object.isRequired
transports : PropTypes.object.isRequired
};
const makeMapStateToProps = () =>