@observertc/client-monitor-js
Version:
ObserveRTC Client Integration Javascript Library
1 lines • 941 B
JavaScript
import{ClientEventTypes as e}from"../schema/ClientEventTypes";export class LongPcConnectionEstablishmentDetector{peerConnection;name="long-pc-connection-establishment-detector";disabled=!1;get config(){return this.peerConnection.parent.config.longPcConnectionEstablishmentDetector}_evented=!1;constructor(e){this.peerConnection=e}update(){if(this.disabled)return;if("connecting"!==this.peerConnection.connectionState)return void(this._evented=!1);if(this._evented)return;if(void 0===this.peerConnection.connectingStartedAt)return;const n=Date.now()-this.peerConnection.connectingStartedAt;if(n<this.config.thresholdInMs)return;this._evented=!0;const t=this.peerConnection.parent;t.emit("too-long-pc-connection-establishment",{peerConnectionMonitor:this.peerConnection,clientMonitor:t}),this.config.createEvent&&t.addEvent({type:e.LONG_PC_CONNECTION_ESTABLISHMENT,payload:{peerConnectionId:this.peerConnection.peerConnectionId,duration:n}})}}