@@ -84,17 +84,14 @@ const userFacingDiagnostics = call.feature(Features.UserFacingDiagnostics);
84
84
85
85
## Local User Facing Diagnostic events
86
86
87
- - Subscribe to the ` diagnosticChanged ` event to monitor when any user-facing diagnostic changes.
87
+
88
+ Each diagnostic has the following data:
89
+ - Diagnostic is the type of diagnostic. For example a UFD of NetworkSendQuality, DeviceSpeakWhileMuted, etc...
90
+ - value is DiagnosticQuality or DiagnosticFlag:
91
+ - DiagnosticQuality = enum { Good = 1, Poor = 2, Bad = 3 }.
92
+ - DiagnosticFlag = true | false.
88
93
89
94
``` js
90
- /**
91
- * Each diagnostic has the following data:
92
- * - diagnostic is the type of diagnostic, for example NetworkSendQuality, DeviceSpeakWhileMuted, and so on.
93
- * - value is DiagnosticQuality or DiagnosticFlag:
94
- * - DiagnosticQuality = enum { Good = 1, Poor = 2, Bad = 3 }.
95
- * - DiagnosticFlag = true | false.
96
- * - valueType = 'DiagnosticQuality' | 'DiagnosticFlag'
97
- */
98
95
const diagnosticChangedListener = (diagnosticInfo : NetworkDiagnosticChangedEventArgs | MediaDiagnosticChangedEventArgs ) => {
99
96
console .log (` Diagnostic changed: ` +
100
97
` Diagnostic: ${ diagnosticInfo .diagnostic } ` +
@@ -116,54 +113,48 @@ const diagnosticChangedListener = (diagnosticInfo: NetworkDiagnosticChangedEvent
116
113
}
117
114
};
118
115
116
+
117
+ // Subscribe to the `diagnosticChanged` event to monitor when any local user-facing diagnostic changes.
118
+
119
119
userFacingDiagnostics .network .on (' diagnosticChanged' , diagnosticChangedListener);
120
120
userFacingDiagnostics .media .on (' diagnosticChanged' , diagnosticChangedListener);
121
121
```
122
122
123
- ## Using Remote User Facing Diagnostics
123
+ ## Accessing Remote User Facing Diagnostic events
124
+ RemoteParticipantDiagnosticsData has the folloiwng data
125
+ - diagnostic contains array of diagnostics e.g. ServerConnection.
126
+ - value is DiagnosticQuality or DiagnosticFlag:
127
+ - DiagnosticQuality = enum { Good = 1, Poor = 2, Bad = 3 }.
128
+ - DiagnosticFlag = true | false.
129
+ - valueType of the array = 'DiagnosticQuality' | 'DiagnosticFlag'
124
130
125
131
``` js
126
- /** *************
127
- * Interfaces **
128
- ***************/
129
- export declare type RemoteDiagnostic = {
130
- // Remote participant's Id
131
- readonly participantId : string ;
132
- // This is the MRI of the remote participant.
133
- readonly rawId : string ;
134
- // Remote partcipant Object
135
- readonly remoteParticipant ?: RemoteParticipant ;
136
- // Name of the diagnostic
137
- readonly diagnostic : NetworkDiagnosticType | MediaDiagnosticType | ServerDiagnosticType ;
138
- // Value of the diagnostic
139
- readonly value : DiagnosticQuality | DiagnosticFlag ;
140
- // Value type of the diagnostic, "DiagnosticFlag" or "DiagnosticQuality"
141
- readonly valueType : DiagnosticValueType ;
142
- };
143
- export declare interface RemoteParticipantDiagnosticsData {
144
- diagnostics : RemoteDiagnostic [];
145
- }
132
+ const remoteDiagnosticChangedListener = (diagnosticInfo : RemoteParticipantDiagnosticsData ) => {
133
+ for (const diagnostic of diagnosticInfo .diagnostics ) {
134
+ if (diagnostic .valueType === ' DiagnosticQuality' ) {
135
+ if (diagnostic .value === SDK .DiagnosticQuality .Bad ) {
136
+ console .error (` ${ diagnostic .diagnostic } is bad quality` );
146
137
138
+ } else if (diagnostic .value === SDK .DiagnosticQuality .Poor ) {
139
+ console .error (` ${ diagnostic .diagnostic } is poor quality` );
140
+ }
147
141
148
- /** ***************
149
- * Sample usage **
150
- *****************/
151
- const remoteUfdsFeature = call .feature (Features .UserFacingDiagnostics ).remote ;
142
+ } else if (diagnostic .valueType === ' DiagnosticFlag' ) {
143
+ console .error (` ${ diagnostic .diagnostic } diagnostic flag raised` );
144
+ }
145
+ }
146
+ };
152
147
153
- // Listen for remote client UFDs. These are UFDs raised from remote participants.
154
- const remoteDiagnosticChangedListener = (diagnosticInfo : RemoteParticipantDiagnosticsData ) => {
155
- for (const diagnostic of diagnosticInfo .diagnostics ) {
156
- console .error (` Remote participant diagnostic: ${ diagnostic .diagnostic } = ${ diagnostic .value } ` );
157
- }
158
- }
159
- remoteUfdsFeature .on (' diagnosticChanged' , remoteDiagnosticChangedListener);
148
+ // Subscribe to the `diagnosticChanged` event to monitor when any local user-facing diagnostic changes.
149
+ userFacingDiagnostics .remote .on (' diagnosticChanged' , remoteDiagnosticChangedListener);
160
150
161
151
// Start sending local UFDs to remote clients. Must call this API so that local UFDs can start sending out and remote clients can receive them.
162
152
remoteUfdsFeature .startSendingDiagnostics ();
163
153
// Stop sending local UFDs to remote clients.
164
154
remoteUfdsFeature .stopSendingDiagnostics ();
165
155
166
156
157
+
167
158
## Raise the latest User Facing Diagnostics fired off
168
159
169
160
Here is sample code to generate the latest diagnostic value raised by the calling SDK . If a diagnostic is undefined , it means the UFD has not been raised.
@@ -202,4 +193,4 @@ console.log(
202
193
` microphoneNotFunctioning: ${latestMediaDiagnostics .microphoneNotFunctioning .value }, ` +
203
194
` value type = ${latestMediaDiagnostics .microphoneNotFunctioning .valueType }`
204
195
);
205
- ` ` `
196
+
0 commit comments