Skip to content

Commit 7978909

Browse files
authored
Update 5
1 parent 1a2f139 commit 7978909

File tree

1 file changed

+33
-42
lines changed

1 file changed

+33
-42
lines changed

articles/communication-services/concepts/voice-video-calling/includes/user-facing-diagnostics-web.md

Lines changed: 33 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -84,17 +84,14 @@ const userFacingDiagnostics = call.feature(Features.UserFacingDiagnostics);
8484

8585
## Local User Facing Diagnostic events
8686

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.
8893

8994
```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-
*/
9895
const diagnosticChangedListener = (diagnosticInfo: NetworkDiagnosticChangedEventArgs | MediaDiagnosticChangedEventArgs) => {
9996
console.log(`Diagnostic changed: ` +
10097
`Diagnostic: ${diagnosticInfo.diagnostic}` +
@@ -116,54 +113,48 @@ const diagnosticChangedListener = (diagnosticInfo: NetworkDiagnosticChangedEvent
116113
}
117114
};
118115

116+
117+
// Subscribe to the `diagnosticChanged` event to monitor when any local user-facing diagnostic changes.
118+
119119
userFacingDiagnostics.network.on('diagnosticChanged', diagnosticChangedListener);
120120
userFacingDiagnostics.media.on('diagnosticChanged', diagnosticChangedListener);
121121
```
122122

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'
124130

125131
```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`);
146137

138+
} else if (diagnostic.value === SDK.DiagnosticQuality.Poor) {
139+
console.error(`${diagnostic.diagnostic} is poor quality`);
140+
}
147141

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+
};
152147

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);
160150

161151
// 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.
162152
remoteUfdsFeature.startSendingDiagnostics();
163153
// Stop sending local UFDs to remote clients.
164154
remoteUfdsFeature.stopSendingDiagnostics();
165155

166156

157+
167158
## Raise the latest User Facing Diagnostics fired off
168159

169160
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(
202193
`microphoneNotFunctioning: ${latestMediaDiagnostics.microphoneNotFunctioning.value}, ` +
203194
`value type = ${latestMediaDiagnostics.microphoneNotFunctioning.valueType}`
204195
);
205-
```
196+

0 commit comments

Comments
 (0)