Detecting audio and video quality changes (JavaScript Only)
If a client experiences periods of degraded network connectivity, this may be reflected on the
subscriber call quality. The Subscriber object dispatches a qualityScoreChanged event
when the calculated audio and video MOS scores change. These scores are reported as integers between 1 (worst) and 5 (best),
corresponding to bad, poor, fair, good, and excellent. For more details, see the Subscriber qualityScoreChanged event.
A Subscriber object dispatches this event only when one of the quality scores has changed. Each Subscribe dispatches events with its own audio and video quality scores, depending on whether it is subscribing to audio, video, or both.
In response to these events, your application can (optionally) notify the client of network conditions resulting in degraded call quality:
subscriber.on('qualityScoreChanged', ({qualityScore}) => {
if (qualityScore.audioQualityScore <= 3){
// Alert the user that the remote party is experiencing degraded service
}
if (qualityScore.videoQualityScore <= 3){
// Alert the user that the remote party is experiencing degraded service
}
});
Automatic reconnection
If a client drops a connection to a subscribed stream (for example, due to a network issue), it will attempt to automatically reconnect to the stream.
If a client drops a connection to a subscribed stream (for example, due to a drop in network connectivity in either client), it will attempt to automatically reconnect to the stream. When the stream is dropped and the client tries to reconnect, the OTSubscriber object dispatches a disconnected event. When the stream is restored, the OTSubscriber object dispatches a connected event. If the client cannot restore the stream, the OTSubscriber object dispatches a destroyed event.
In response to these events, your application can (optionally) display user interface notifications indicating the temporary disconnection, reconnection, and destroyed states:
<OTSubscriber
eventHandlers={{
disconnected: (event) => {
console.log('stream disconnected -- stream ID:', event.streamId);
// Display a user interface notification.
},
connected: (event) => {
console.log('stream connected -- stream ID:', event.streamId);
// Adjust user interface.
},
destroyed: (event) => {
console.log('stream destroyed -- stream ID:', event.streamId);
// Adjust user interface.
}
}}/>
The Subscriber object dispatches a disconnected event. When the stream is restored, the Subscriber object dispatches a connected event. If the client cannot restore the stream, the Subscriber object dispatched a destroyed event.
In response to these events, your application can (optionally) display user interface notifications indicating the temporary disconnection, reconnection, and destroyed states:
subscriber.on(
disconnected: function() {
// Display a user interface notification.
},
connected: function() {
// Adjust user interface.
},
destroyed: function() {
// Adjust user interface.
}
);
The SubscriberKit.StreamListener.onDisconnected(SubscriberKit subscriber) method is called. When the connection is restored, the SubscriberKit.StreamListener.onReconnected(SubscriberKit subscriber) method is called. If the client cannot restore the stream, the Session.SessionListener.onStreamDropped(Session session, Stream stream) method is called.
In response to these events, your application can (optionally) display user interface notifications indicating the temporary disconnection, reconnection, and destroyed states:
The OTSubscriberDelegate subscriberDidDisconnect(fromStream:) message is sent to the OTSubscriber object's delegate.
When the connection is restored, the OTSubscriberDelegate subscriberDidReconnect(toStream:) message is sent. If the client cannot restore the connection, the OTSessionDelegate session(_:streamDestroyed:) message is sent.
In response to these events, your application can (optionally) display user interface notifications indicating the temporary disconnection, reconnection, and disconnection states.
When the stream is dropped and the client tries to reconnect, the [OTSubscriberKitDelegate subscriberDidDisconnectFromStream:] message is sent to the OTSubscriberKit object's delegate.
When the connection is restored, the [OTSubscriberKitDelegate subscriberDidReconnectToStream:] message is sent. If the client cannot restore the connection, the [OTSessionDelegate session:streamDestroyed:] message is sent.
In response to these events, your application can (optionally) display user interface notifications indicating the temporary disconnection, reconnection, and disconnection states.
The Session object sends a StreamDisconnected event.
When the connection is restored, the Subscriber object sends a StreamReconnected event. If the client cannot restore the stream, the Session object sends a StreamDropped event.
In response to these events, your application can (optionally) display user interface notifications indicating the temporary disconnection, reconnection, and destroyed states:
When the stream is dropped and the client tries to reconnect, the on_disconnected callback function of the otc_subscriber_callbacks struct for the subscriber is called. When the connection is restored, the on_reconnected callback function of the otc_subscriber_callbacks struct for the subscriber is called.
If the client cannot restore the stream, the on_stream_dropped callback function of the otc_session_callbacks struct is called.
In response to these events, your application can (optionally) display user interface notifications indicating the temporary disconnection, reconnection, and destroyed states: