@observertc/client-monitor-js
Version:
ObserveRTC Client Integration Javascript Library
1 lines • 946 B
JavaScript
export class LongPcConnectionEstablishmentDetector{peerConnection;name="long-pc-connection-establishment-detector";get config(){return this.peerConnection.parent.config.longPcConnectionEstablishmentDetector}_evented=!1;constructor(n){this.peerConnection=n}update(){if(this.config.disabled)return;if("connecting"!==this.peerConnection.connectionState)return this._evented&&"connected"===this.peerConnection.connectionState?void(this._evented=!1):void 0;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 e=this.peerConnection.parent;e.emit("too-long-pc-connection-establishment",{peerConnectionMonitor:this.peerConnection,clientMonitor:e}),this.config.createIssue&&e.addIssue({type:"long-pc-connection-establishment",payload:{peerConnectionId:this.peerConnection.peerConnectionId,duration:n}})}}