@100mslive/hms-video-store
Version:
@100mslive Core SDK which abstracts the complexities of webRTC while providing a reactive store for data management with a unidirectional data flow
23 lines (20 loc) • 804 B
text/typescript
import { HMSConnectionQuality, HMSConnectionQualityListener } from '../../interfaces';
import { Store } from '../../sdk/store';
import { ConnectionQualityList } from '../HMSNotifications';
export class ConnectionQualityManager {
constructor(private store: Store, public listener?: HMSConnectionQualityListener) {}
handleQualityUpdate(qualityList: ConnectionQualityList) {
const peers = qualityList.peers;
const hmsPeers: HMSConnectionQuality[] = peers.map(peer => {
const storePeer = this.store.getPeerById(peer.peer_id);
if (storePeer) {
storePeer.updateNetworkQuality(peer.downlink_score);
}
return {
peerID: peer.peer_id,
downlinkQuality: peer.downlink_score,
};
});
this.listener?.onConnectionQualityUpdate(hmsPeers);
}
}