Skip to content

Network Quality events

Ajša Terko edited this page Apr 12, 2024 · 4 revisions

To provide better feedback during RTC calls, you can subscribe to network quality events.

These events are used to inform the user on both their local network quality and that of the remote participants. By receiving this information, users can understand how call quality may be impacted by fluctuations in network quality, whether it is on their end or that of the remote participants.

To utilize these events, it is essential to subscribe to the NETWORK_QUALITY_CHANGED event for the updates on the local network quality and PARTICIPANT_NETWORK_QUALITY_CHANGED event for the updates on the network quality of the remote participants. You can achieve this by using the on method on the instance of either the ApplicationCall or the RoomCall, as demonstrated in the following example:

let applicationCall = infobipRTC.callApplication('45g2gql9ay4a2blu55uk1628');

applicationCall.on(CallsApiEvent.NETWORK_QUALITY_CHANGED, event => 
    console.log(`Local network quality is: ${NetworkQuality[event.networkQuality]}`)
);
applicationCall.on(CallsApiEvent.PARTICIPANT_NETWORK_QUALITY_CHANGED, event => 
    console.log(`Network quality of ${event.participant.endpoint.identifier} is: ${NetworkQuality[event.networkQuality]}`)
);

Similarly, updates on the network quality are available for the WebrtcCall. However, to utilize these events, it is essential to subscribe to the REMOTE_NETWORK_QUALITY_CHANGED event instead of the PARTICIPANT_NETWORK_QUALITY_CHANGED event, as demonstrated in the following example:

let webrtCall = infobipRTC.callWebrtc('alice');

webrtCall.on(CallsApiEvent.NETWORK_QUALITY_CHANGED, event => 
    console.log(`Local network quality is: ${NetworkQuality[event.networkQuality]}`)
);
webrtCall.on(CallsApiEvent.REMOTE_NETWORK_QUALITY_CHANGED, event =>
    console.log(`Remote network quality is: ${NetworkQuality[event.networkQuality]}`)
);

Additionally, the local network quality events are available for both the PhoneCall and the ViberCall.

Each of these events includes a NetworkQuality object which is an enum that describes the network quality in five levels, ranging from BAD to EXCELLENT. The numerical values of these enums span from 1 to 5, the latter being the best quality correlating to EXCELLENT.

It is important to recognize that the network quality is highly dependent on the specific use-case demands. A network of an excellent quality during a voice call might experience a drop to a fair quality once video is enabled.

Tutorials

Migration guides

Reference documentation

Clone this wiki locally