diff --git a/app/src/RoomClient.js b/app/src/RoomClient.js index 9e5b6ff..e22341c 100644 --- a/app/src/RoomClient.js +++ b/app/src/RoomClient.js @@ -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) { diff --git a/app/src/components/Containers/Me.js b/app/src/components/Containers/Me.js index 9145475..bde4a5c 100644 --- a/app/src/components/Containers/Me.js +++ b/app/src/components/Containers/Me.js @@ -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 (