99 Logger ,
1010 StatsReportItem ,
1111 WebRTCIssueDetectorConstructorParams ,
12- WebRTCStatsParsed ,
12+ NetworkScoresPayload ,
1313 WIDWindow ,
1414} from './types' ;
1515import PeriodicWebRTCStatsReporter from './parser/PeriodicWebRTCStatsReporter' ;
@@ -85,12 +85,10 @@ class WebRTCIssueDetector {
8585 this . wrapRTCPeerConnection ( ) ;
8686 }
8787
88- this . statsReporter . on ( PeriodicWebRTCStatsReporter . STATS_REPORT_READY_EVENT , ( report : StatsReportItem ) => {
89- this . detectIssues ( {
90- data : report . stats ,
91- } ) ;
88+ this . statsReporter . on ( PeriodicWebRTCStatsReporter . STATS_REPORT_READY_EVENT , ( { stats, id } : StatsReportItem ) => {
89+ this . detectIssues ( { data : stats } ) ;
9290
93- this . calculateNetworkScores ( report . stats ) ;
91+ this . calculateNetworkScores ( { data : stats , id } ) ;
9492 } ) ;
9593
9694 this . statsReporter . on ( PeriodicWebRTCStatsReporter . STATS_REPORTS_PARSED , ( data : { timeTaken : number } ) => {
@@ -131,7 +129,7 @@ class WebRTCIssueDetector {
131129 this . statsReporter . stopReporting ( ) ;
132130 }
133131
134- public handleNewPeerConnection ( pc : RTCPeerConnection ) : void {
132+ public handleNewPeerConnection ( pc : RTCPeerConnection , id ?: string ) : void {
135133 if ( ! this . #running && this . autoAddPeerConnections ) {
136134 this . logger . debug ( 'Skip handling new peer connection. Detector is not running' , pc ) ;
137135 return ;
@@ -143,9 +141,9 @@ class WebRTCIssueDetector {
143141 this . statsReporter . startReporting ( ) ;
144142 }
145143
146- this . logger . debug ( ' Handling new peer connection' , pc ) ;
144+ this . logger . debug ( ` Handling new peer connection with id ${ id } ` , pc ) ;
147145
148- this . compositeStatsParser . addPeerConnection ( { pc } ) ;
146+ this . compositeStatsParser . addPeerConnection ( { pc, id } ) ;
149147 }
150148
151149 private emitIssues ( issues : IssuePayload [ ] ) : void {
@@ -159,8 +157,8 @@ class WebRTCIssueDetector {
159157 }
160158 }
161159
162- private calculateNetworkScores ( data : WebRTCStatsParsed ) : void {
163- const networkScores = this . networkScoresCalculator . calculate ( data ) ;
160+ private calculateNetworkScores ( payload : NetworkScoresPayload ) : void {
161+ const networkScores = this . networkScoresCalculator . calculate ( payload ) ;
164162 this . eventEmitter . emit ( EventType . NetworkScoresUpdated , networkScores ) ;
165163 }
166164
0 commit comments