9
9
Logger ,
10
10
StatsReportItem ,
11
11
WebRTCIssueDetectorConstructorParams ,
12
- WebRTCStatsParsed ,
12
+ NetworkScoresPayload ,
13
13
WIDWindow ,
14
14
} from './types' ;
15
15
import PeriodicWebRTCStatsReporter from './parser/PeriodicWebRTCStatsReporter' ;
@@ -85,12 +85,10 @@ class WebRTCIssueDetector {
85
85
this . wrapRTCPeerConnection ( ) ;
86
86
}
87
87
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 } ) ;
92
90
93
- this . calculateNetworkScores ( report . stats ) ;
91
+ this . calculateNetworkScores ( { data : stats , id } ) ;
94
92
} ) ;
95
93
96
94
this . statsReporter . on ( PeriodicWebRTCStatsReporter . STATS_REPORTS_PARSED , ( data : { timeTaken : number } ) => {
@@ -131,7 +129,7 @@ class WebRTCIssueDetector {
131
129
this . statsReporter . stopReporting ( ) ;
132
130
}
133
131
134
- public handleNewPeerConnection ( pc : RTCPeerConnection ) : void {
132
+ public handleNewPeerConnection ( pc : RTCPeerConnection , id ?: string ) : void {
135
133
if ( ! this . #running && this . autoAddPeerConnections ) {
136
134
this . logger . debug ( 'Skip handling new peer connection. Detector is not running' , pc ) ;
137
135
return ;
@@ -143,9 +141,9 @@ class WebRTCIssueDetector {
143
141
this . statsReporter . startReporting ( ) ;
144
142
}
145
143
146
- this . logger . debug ( ' Handling new peer connection' , pc ) ;
144
+ this . logger . debug ( ` Handling new peer connection with id ${ id } ` , pc ) ;
147
145
148
- this . compositeStatsParser . addPeerConnection ( { pc } ) ;
146
+ this . compositeStatsParser . addPeerConnection ( { pc, id } ) ;
149
147
}
150
148
151
149
private emitIssues ( issues : IssuePayload [ ] ) : void {
@@ -159,8 +157,8 @@ class WebRTCIssueDetector {
159
157
}
160
158
}
161
159
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 ) ;
164
162
this . eventEmitter . emit ( EventType . NetworkScoresUpdated , networkScores ) ;
165
163
}
166
164
0 commit comments